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] |
| searchReports, | ||
| policy, | ||
| }: GetMergeFieldUpdatedValuesParams<K>): MergeTransactionUpdateValues { | ||
| const transactionDetails = getTransactionDetails(transaction); |
There was a problem hiding this comment.
❌ PERF-2 (docs)
getTransactionDetails(transaction) and getMergeFieldValue(...) are hoisted to run unconditionally at the top of getMergeFieldUpdatedValues, but they are only used in the field === 'amount' and field === 'merchant' && isDistanceRequest(transaction) branches. getTransactionDetails performs non-trivial work (report lookups, amount calculations). When field is 'reportID' or 'taxValue', these computations are wasted.
Keep transactionDetails and amount computed inside the branches that need them. For reuse across both branches, compute them lazily:
let transactionDetails: TransactionDetails | undefined;
let amount: number | undefined;
function getAmount() {
if (amount === undefined) {
transactionDetails ??= getTransactionDetails(transaction);
amount = getMergeFieldValue(transactionDetails, transaction, 'amount') as number;
}
return amount;
}Or simply duplicate the two lines in both branches since they are short.
Reviewed at: bc3a174 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
@dominictb what do you think about this feedback? I agree that we should keep it as it
There was a problem hiding this comment.
I agree that we should keep it as it
@hoangzinh Do you mean to follow AI suggestion or my approach?
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc3a1748a3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const isTaxEnabled = isTaxTrackingEnabled(isPolicyExpenseChat || isExpenseUnreported, policy, isDistanceRequest, isPerDiemRequest, isTimeRequest); | ||
| const shouldShowTaxDisabledAlert = !isTaxEnabled && !!transaction?.taxCode && !isTimeRequest && !isPerDiemRequest; | ||
| const shouldShowTax = isTaxEnabled || !!transaction?.taxName || shouldShowTaxDisabledAlert; | ||
| const shouldShowTax = isFromMergeTransaction ? !!transaction?.taxName : isTaxEnabled || shouldShowTaxDisabledAlert; |
There was a problem hiding this comment.
This is to fix Test case 1 in OP
| searchReports, | ||
| policy, | ||
| }: GetMergeFieldUpdatedValuesParams<K>): MergeTransactionUpdateValues { | ||
| const transactionDetails = getTransactionDetails(transaction); |
There was a problem hiding this comment.
@dominictb what do you think about this feedback? I agree that we should keep it as it
| if (mergeTransaction?.taxValue && transaction?.amount) { | ||
| updatedValues.taxAmount = convertToBackendAmount(calculateTaxAmount(mergeTransaction?.taxValue, transaction.amount, getCurrencyDecimals(getCurrency(transaction)))); | ||
| if (mergeTransaction?.taxValue && amount) { | ||
| updatedValues.taxAmount = convertToBackendAmount(calculateTaxAmount(mergeTransaction?.taxValue, amount, getCurrencyDecimals(getCurrency(transaction)))); |
There was a problem hiding this comment.
@dominictb, can you confirm if you want to use the amount after format? It will cause the amount to be negative/possitive sign.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
trjExpensify
left a comment
There was a problem hiding this comment.
Let's get it done! 👍
…ix/delete-tax-followups
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeScreen.Recording.2026-04-20.at.23.22.25.moviOS: HybridAppiOS: mWeb SafariScreen.Recording.2026-04-20.at.23.52.20.movMacOS: Chrome / SafariScreen.Recording.2026-04-20.at.23.16.06.mov |
|
@dominictb I'm still able to reproduce this DB #87640 on this PR Screen.Recording.2026-04-20.at.23.06.22.mov |
|
@hoangzinh That is being worked on in this backend PR. Regarding #87640, this PR only covers the |
|
✋ 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/youssef-lr in version: 9.3.61-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes required. I reviewed the code changes in this PR — they are internal bug fixes to tax field handling during expense merging:
These changes fix existing behavior without introducing new user-facing features, workflows, buttons, or labels. The existing How to Merge Expenses article already covers the merge flow generically ("Choose which expense details to apply to the final expense"), which remains accurate after these fixes. |
Explanation of Change
Fixed Issues
$ #87640
$ #87578
PROPOSAL:
Tests
Test case 1: Distance expense
Preconditions:
Test case 2: Scan expense
Offline tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Tax fields are not on time and per diem expenses:
Distance expenses:
Screen.Recording.2026-04-15.at.22.40.14.mov
Scan expenses:
Screen.Recording.2026-04-15.at.22.41.42.mov