Repository navigation
Keep the tax sign of a merged expense in line with its amount offline - #103677
Conversation
The merge flow calculated the tax from the stored amount, which has the opposite sign on expense reports, so a merged negative expense showed a positive tax until the server responded. Calculate it from the displayed amount instead, carry over the displayed tax for distance expenses, and show the merge preview's tax as is. Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
| const formattedTaxAmount = convertToDisplayString(transactionTaxAmount ?? 0, actualCurrency); | ||
| // Use the updated transaction tax amount in merge flow to have correct positive/negative sign | ||
| const actualTaxAmount = isFromMergeTransaction && updatedTransaction ? updatedTransaction.taxAmount : transactionTaxAmount; | ||
| const formattedTaxAmount = convertToDisplayString(actualTaxAmount ?? 0, actualCurrency); |
There was a problem hiding this comment.
@MelvinBot hmm, this makes me think the mergeTransaction taxAmount should be stored as a stored value instead of displayed value. Why would it be different?
There was a problem hiding this comment.
Keep it displayed. The save path already negates mergeTransaction.amount once and diffs against displayed values, so a stored-sign tax would get flipped on write. Mark it ready and I'll review for the CP
|
The bug came from the |
|
@MelvinBot add this to QA Steps Precondition:
Update Test steps and Offline steps to be "Same as QA Steps" |
|
Updated the PR description:
I kept the "Verify that no errors appear in the JS console" checkbox in Tests and QA Steps. The rest of the description is unchanged. |
|
@MelvinBot replace the PR Author Checklist section with below PR Author Checklist
and replace the Screenshots/Videos section with below. Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / Safariweb.mp4Then, check all "Verify that no errors appear in the JS console". Last, mark the PR as ready for review. You can do it! |
|
🤖 Done. I updated the PR description and marked this PR ready for review:
|
|
@ikevin127 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🚧 grgia has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/grgia in version: 9.5.8-0 🚀
|
|
No help site update is needed. This bug fix makes a merged negative expense show a negative tax amount while offline, which is what users already expect, and no article sentence describes the old behavior. |
|
@bernhardoj Tax amount field is not negative 1791899583717.11-web.mp4 |
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.5.8-5 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to staging by https://github.com/grgia in version: 9.5.9-0 🚀
|
|
No help site update is needed. This bug fix only corrects the tax sign that merged negative expenses show offline before the server responds, which is the behavior users already expect. |
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.5.9-4 🚀
Bundle Size Analysis (Sentry): |




Explanation of Change
When you merge two negative expenses offline, the merged expense showed a positive tax amount until the server responded.
The merge flow keeps values in
mergeTransactionwith the sign they are displayed with. When you pick the amount, though,getMergeFieldUpdatedValuescalculated the tax from the transaction's stored amount. On expense reports, the stored amount has the opposite sign. The tax got the wrong sign, and the offline update flipped it again. Show negative tax amount for negative expenses on the expense details page removed aMath.abs()that had been hiding this.This PR:
fieldValue), as thetaxValuebranch already does withmergeTransaction.amount.transactionDetails.taxAmount) instead of the raw stored tax when you pick a distance merchant.MoneyRequestView, the same way that preview already usesupdatedTransaction.amount. Otherwise the now correctly signed tax would be flipped again on the confirmation page.The server ignores this value because
MergeTransactiondoesn't sendtaxAmount. This change only fixes the optimistic offline data and the preview.Fixed Issues
$ #103671
PROPOSAL: #103671 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Precondition:
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mp4