-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[$250] Search - Total amount does not auto update after changing the expense currency #49493
Comments
Triggered auto assignment to @CortneyOfstad ( |
We think that this bug might be related to #wave-control |
@CortneyOfstad FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors |
ProposalPlease re-state the problem that we are trying to solve in this issue.Total amount does not auto update after changing the expense currency What is the root cause of that problem?We compute the total here Line 80 in 25450d9
However, this function ( App/src/components/Search/index.tsx Lines 96 to 98 in 25450d9
What changes do you think we should make in order to solve the problem?Instead of reading from the Replace this line
with the following code
A similar approach is already implemented for reports. Finally, we can remove the Line 80 in 25450d9
|
@CortneyOfstad Whoops! This issue is 2 days overdue. Let's get this updated quick! |
So one aspect here is missing — the default currency in the workspace. If the default currency is set to MHR, then the total amount did update. I am not able to recreate this as the expense converts to the home currency of the workspace. Going to have this retested. |
This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989 |
@CortneyOfstad Whoops! This issue is 2 days overdue. Let's get this updated quick! |
@CortneyOfstad 6 days overdue. This is scarier than being forced to listen to Vogon poetry! |
Still waiting for this to be retested! |
@CortneyOfstad this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks! |
Not overdue as waiting for this to be retested! |
Again, still waiting for this to be retested! |
This issue is still reproducible. To clarify as the title is a bit misleading - the total amount does update, but not to the correct value. It should be around 1500 but it's showing as 1212. Refreshing the page displays the correct amount. |
@CortneyOfstad Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
Thanks @CyberAndrii! |
Current assignee @situchan is eligible for the External assigner, not assigning anyone new. |
Not overdue, waiting for review or more proposals |
@huult I don't think your new solution is correct. I don't get how that change in Onyx fixes the root cause and it will easily cause regressions. |
@situchan After calling After that, we will loop through the data in In this ticket, the data contains two items ( So, the final updatedData will have report_ as an empty object {}, and the report_ in the snapshot will not be updated. As a result, the total amount will not be changed. To resolve this issue, I think we have two possible approaches:
We need to update the condition to prevent assigning an empty object to a key that has existing new data. If updatedData[key] contains data and newValue is empty, we should skip assigning this value to updatedData //.lib/Onyx.ts#L273
- updatedData = {...updatedData, [key]: lodashPick(value, Object.keys(snapshotData[key]))};
+ const newValue = lodashPick(value, Object.keys(snapshotData[key]))
+ if (updatedData[key] && !utils.isEmptyObject(updatedData[key]) && utils.isEmptyObject(newValue)) {
+ return
+ }
+ updatedData = {...updatedData, [key]: newValue}; Code example change in node_modules to test: //.App/node_modules/react-native-onyx/dist/Onyx.js#L483
data.forEach(({ key, value }) => {
// snapshots are normal keys so we want to skip update if they are written to Onyx
if (OnyxUtils_1.default.isCollectionMemberKey(snapshotCollectionKey, key, snapshotCollectionKeyLength)) {
return;
}
if (typeof snapshotValue !== 'object' || !('data' in snapshotValue)) {
return;
}
const snapshotData = snapshotValue.data;
if (!snapshotData || !snapshotData[key]) {
return;
}
+ if (updatedData[key] && Object.keys(updatedData[key]).length && !Object.keys((0, pick_1.default)(value, Object.keys(snapshotData[key]))).length) {
+ return;
+ }
updatedData = Object.assign(Object.assign({}, updatedData), { [key]: (0, pick_1.default)(value, Object.keys(snapshotData[key])) });
}); |
Proposal updated
|
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
This bug only happens when change currency. |
I saw this bug happen when we call
This issue still happens in USD. You can see that the total change reflects the previous
This issue happens with all currencies. The total does not change when updating the amount in a currency other than USD. This is because when you change the amount, the response update is delayed compared to USD. If you wait for the response before changing, the behavior will be the same as with USD. Lines 2627 to 2630 in 224b633
This is still updated incorrectly because it is being updated by the previous Lines 58 to 61 in 7216310
Therefore, you can see the total amount change, which comes from the The video I mentioned describes thatScreen.Recording.2024-10-31.at.22.39.19.mp4 |
@huult thanks. Can we also think of an alternative solution? So instead of fully overwriting, only update picked field values?
|
We can assign @huult for providing the correct root cause and proper solution. The root cause is in Onyx. |
Current assignee @marcochavezf is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new. |
📣 @situchan 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @huult 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
Thank you all. I will create the PR within 24 hours |
I created a pull request. Can you check it? I saw my pull request was auto-assigned to @rlinoz. Thanks! |
PR merged, not overdue |
Should we hold this for #51942 or bump version to v2.0.79 in that PR? |
I've created a pull request to bump the Onyx version to 2.0.79. |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.38-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Action Performed:
Expected Result:
The total amount should auto update after changing the expense currency.
Actual Result:
The total amount does not auto update after changing the expense currency.
Workaround:
Unknown
Platforms:
Screenshots/Videos
Bug6608678_1726739142065.bandicam_2024-09-19_17-41-06-770.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @The text was updated successfully, but these errors were encountered: