-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[Merge] Merging tax rates #71244
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
base: main
Are you sure you want to change the base?
[Merge] Merging tax rates #71244
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@hoangzinh 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] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
src/libs/MergeTransactionUtils.ts
Outdated
| const taxAmountInSmallestCurrencyUnits = convertToBackendAmount(Number.parseFloat(taxAmount.toString())); | ||
| return taxAmountInSmallestCurrencyUnits; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to convert taxAmount to a string, then parse it to a float? Besides that, I guess we can put this function into TransactionUtils to reuse later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied from here:
App/src/components/MoneyRequestConfirmationList.tsx
Lines 540 to 541 in b5f7c02
| const taxAmount = calculateTaxAmount(taxPercentage, taxableAmount, transaction.currency); | |
| const taxAmountInSmallestCurrencyUnits = convertToBackendAmount(Number.parseFloat(taxAmount.toString())); |
But I think it's not needed. It was initially added because calculateTaxAmount previously did not handle floating-point precision.
App/src/components/MoneyRequestConfirmationList.tsx
Lines 540 to 541 in b5f7c02
| const taxAmount = calculateTaxAmount(taxPercentage, taxableAmount, transaction.currency); | |
| const taxAmountInSmallestCurrencyUnits = convertToBackendAmount(Number.parseFloat(taxAmount.toString())); |
Just removed that conversion
|
@dominictb can you upload recordings for platform? |
|
I'll add recordings later after implementing the changes that I'm asking Garett in #70058 (comment) |
|
@dominictb, did you get that added? Can you add recordings, and @hoangzinh can you start review? |
|
@trjExpensify I finished code review. Whenever @dominictb uploads his recordings, I will complete review checklist |
|
Clarifying some points in the issue thread #70058 |
|
This only happens if I initiate the merge flow from the expense that does not have tax enabled. Other cases work fine. Screen.Recording.2025-10-09.at.16.57.44.movIn the @youssef-lr I think this is a BE bug. Can you take a look? |
|
Checking that |
|
I was wrong to assume that other fields had the same bug. Indeed only fields that are dependent on report and policy (report name, workspace, tax,...) are affected. Root cause is we don't update Also here we should retain the source report if it is the selected report to find the corresponding |
|
Is this ready for another review @dominictb? |
|
Yes cc @hoangzinh |
hoangzinh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All goods. I have a few feedback. Going to test PR today
| targetTransactionReport = targetTransactionReport ?? currentSearchResults?.data[`${ONYXKEYS.COLLECTION.REPORT}${targetTransaction?.reportID}`]; | ||
| sourceTransactionReport = sourceTransactionReport ?? currentSearchResults?.data[`${ONYXKEYS.COLLECTION.REPORT}${sourceTransaction?.reportID}`]; | ||
| // If we're on search, search snapshot policies are more up to date | ||
| targetTransactionPolicy = currentSearchResults?.data[`${ONYXKEYS.COLLECTION.POLICY}${targetTransactionReport?.policyID}`]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| targetTransactionPolicy = currentSearchResults?.data[`${ONYXKEYS.COLLECTION.POLICY}${targetTransactionReport?.policyID}`]; | |
| targetTransactionPolicy = targetTransactionPolicy ?? currentSearchResults?.data[`${ONYXKEYS.COLLECTION.POLICY}${targetTransactionReport?.policyID}`]; |
I thought onyx data is more up-to-date than snapshot, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're on search page, the snapshot data is more up to date. See #71244 (comment)
src/libs/MergeTransactionUtils.ts
Outdated
| ) { | ||
| const conflictFields: string[] = []; | ||
| const mergeableData: Record<string, unknown> = {}; | ||
| const mergeableData: Record<string, unknown> = {selectedTransactionByField: {}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate on this change? @dominictb. I'm worried it will reset selected options when this function is triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that makes sense. 6518595
|
Bug: Unable to merge transactions
Screen.Recording.2026-01-07.at.18.25.11.mov |
|
@dominictb can you address the feedback today please? Let's get this over the line! |
|
Sure. I'm closely monitoring this. @hoangzinh Do you have any other concerns or bugs you found? I'm addressing the current ones but appreciate it if we can batch and fix them all. |
|
So far, so good from me. I tried to test various cases yesterday, but it's only bug I found so far. |
|
Nice one! But dammit, we've picked up a conflict. 😮💨 |
|
@youssef-lr I think this #71244 (comment) is a BE bug. When the target workspace has tax enabled but source workspace does not -> |
This reverts commit d14c2b4.
|
The error seems to be coming from here in BE https://github.com/Expensify/Auth/blob/92178dc621df6b83c81536b8cff5ff599a769a2b/auth/lib/Transaction.cpp#L7664 |
|
I think we can ignore the Same thing happens when you moving an expense with tax to a workspace/report without tax, |
|
Gotcha, are we unblocked to continue reviewing this one? |
Oh what I meant in #71244 (comment) is that we need to update backend to do this. Also I resolved @hoangzinh latest feedbacks in f12a935. He can continue reviewing those changes while waiting for the backend update. |
I will manage to review the PR over the weekend, in the meantime |
ah, @youssef-lr @MonilBhavsar do you agree with @dominictb's suggestion above? |
Explanation of Change
Enable users to select tax rate when merging expenses, auto-calculate tax amount.
Fixed Issues
$ #70058
PROPOSAL:
Tests
Test case 1: Merge in the same workspace with tax enabled
Test case 2: Merge in different workspaces with tax enabled in both workspaces
Test case 3: Merge in different workspaces with tax enabled and tax disabled
In review details step, Tax field does not show (it's auto selected depending on destination report).
After merging:
Verify that no errors appear in the JS console
Offline tests
Same as tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
Screen.Recording.2025-11-06.at.15.17.04.mov
Android: mWeb Chrome
Screen.Recording.2025-11-06.at.15.20.35.mov
iOS: Native
Screen.Recording.2025-11-06.at.15.09.13-compressed.mov
iOS: mWeb Safari
Screen.Recording.2025-11-06.at.15.12.26-compressed.mov
MacOS: Chrome / Safari
Test case 1 & 2:
Screen.Recording.2025-10-09.at.17.37.15-compressed.mov
Test case 3:
Screen.Recording.2025-10-17.at.02.49.32.mov
Screen.Recording.2025-10-17.at.02.48.35.mov
MacOS: Desktop
Screen.Recording.2025-11-06.at.15.25.52-compressed.mov