Skip to content

[Due for payment 2026-04-30] [$250] Tax - Confirmation step doesn't show tax amount of A for scan expense #87578

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.58-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #84769
Email or phone of affected tester (no customers): htad26+eryeiuty@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Windows 10 / Chrome, iOS 26.3 / iPhone 13, Android 11
App Component: Money Requests

Action Performed:

  1. Create two workspaces
  2. Enable Taxes feature in one of them
  3. Create 2 scan expenses in those workspaces, one with tax (A), one without tax (B) accordingly
  4. Open A > More > Merge > Select B
  5. Select the report of B > Continue

Expected Result:

The confirmation step shows tax of A

Actual Result:

The confirmation step doesn't show tax amount of A. It is displayed as 0

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Video.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @dominictb
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022042541732841216677
  • Upwork Job ID: 2042541732841216677
  • Last Price Increase: 2026-04-10

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 10, 2026
  2. MelvinBot commented on Apr 10, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    In MergeTransactionUtils.ts, getMergeableDataAndConflictFields() processes fields in the order defined by MERGE_FIELDS (line 41): amount is 1st, taxValue is 7th.

    When two scan expenses have different amounts, amount is added to conflictFields and is not set in mergeableData. When taxValue is then auto-resolved (because only one transaction has tax), getMergeFieldUpdatedValues() is called with mergeTransaction = mergeableData (which has no amount). The guard at line 640 — if (mergeTransaction?.amount) — evaluates to false, so taxAmount is never calculated and defaults to 0.

    What changes do you think we should make in order to solve the problem?

    In getMergeFieldUpdatedValues() at line 640, when field === 'taxValue' and mergeTransaction?.amount is not available, fall back to using transaction?.amount (the selected transaction that has the tax value) to calculate taxAmount. The selected transaction's own amount is a reasonable default for the tax calculation when the merged amount hasn't been determined yet.

    Alternatively, add a post-processing step after the field iteration loop in getMergeableDataAndConflictFields() that recalculates taxAmount if taxValue was set but taxAmount was not.

    What alternative solutions did you explore? (Optional)

    Reordering MERGE_FIELDS to process taxValue after amount doesn't help because when amount is a conflict field, it's never in mergeableData regardless of order.

    Investigation details

    Data flow that produces the bug:

    1. Transaction A has tax (taxValue set, amount=$X), Transaction B has no tax (amount=$Y, X != Y)
    2. getMergeableDataAndConflictFields() iterates MERGE_FIELDS in order
    3. amount: $X != $Y → added to conflictFields, mergeableData.amount remains undefined
    4. taxValue: A has tax, B doesn't → auto-resolves to A's taxValue via the fallback at line 298-311
    5. getMergeFieldUpdatedValues() called with mergeTransaction = mergeableData (no amount) → line 640: if (mergeTransaction?.amount) is false → taxAmount never set
    6. Confirmation page renders via buildMergedTransactionData() → taxAmount: 0

    Note: When the user later manually resolves the amount conflict in DetailsReviewPage, the amount handler at line 606-611 checks mergeTransaction?.taxValue (which IS set by then) and recalculates taxAmount. So the bug is specifically in the initial auto-resolution path, not after user interaction.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 10, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 10, 2026
  5. melvin-bot commented on Apr 10, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @Krishna2323 (External)

  6. MobileMage commented on Apr 10, 2026

    @MobileMage
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When merging two scan expenses where one has a tax rate (A) and the other has no tax (B), the confirmation step displays the tax amount as $0 even though expense A has a valid tax rate and amount.

    What is the root cause of that problem?

    The issue is in getMergeableDataAndConflictFields inside MergeTransactionUtils.ts. When the taxValue field is processed for auto-merging (because B has no tax, making source empty), getMergeFieldUpdatedValues is called to compute taxAmount. Inside that function, the tax amount calculation is gated on mergeTransaction?.amount being truthy:

    if (mergeTransaction?.amount) {
        updatedValues.taxAmount = convertToBackendAmount(calculateTaxAmount(...));
    }

    The mergeTransaction passed here is the partially-built mergeableData object. Because A and B are two distinct scanned expenses, their amounts differ — so amount ends up in conflictFields rather than being set on mergeableData. At the point taxValue is processed in the loop, mergeableData.amount is still undefined, so the condition is falsy and taxAmount is never calculated. The result is mergeTransaction.taxAmount === undefined, which buildMergedTransactionData spreads into the display transaction, showing $0 on the confirmation page.

    if (field === 'taxValue') {
    updatedValues.taxCode = transaction?.taxCode;
    updatedValues.taxName = getTaxName(policy, transaction) ?? transaction?.taxValue ?? '';
    updatedValues.taxPolicyID = policy?.id;
    if (mergeTransaction?.amount) {
    updatedValues.taxAmount = convertToBackendAmount(calculateTaxAmount(transaction?.taxValue, mergeTransaction.amount, getCurrencyDecimals(getCurrency(transaction))));
    }
    }

    What changes do you think we should make in order to solve the problem?

    When taxValue is auto-merged but amount is still unresolved (i.e., is a conflict field), we should fall back to the selected transaction's own taxAmount directly rather than recomputing from scratch. This is safe because the amount conflict will be resolved later on the details review page, and when the user picks an amount there, getMergeFieldUpdatedValues for amount already recalculates taxAmount using the current taxValue. So the fix is to use the transaction's existing taxAmount as the fallback when the mergeTransaction amount is not yet available:

    if (field === 'taxValue') {
    updatedValues.taxCode = transaction?.taxCode;
    updatedValues.taxName = getTaxName(policy, transaction) ?? transaction?.taxValue ?? '';
    updatedValues.taxPolicyID = policy?.id;
    if (mergeTransaction?.amount) {
    updatedValues.taxAmount = convertToBackendAmount(calculateTaxAmount(transaction?.taxValue, mergeTransaction.amount, getCurrencyDecimals(getCurrency(transaction))));
    }
    }

         if (field === 'taxValue') {
             updatedValues.taxCode = transaction?.taxCode;
             updatedValues.taxName = getTaxName(policy, transaction) ?? transaction?.taxValue ?? '';
             updatedValues.taxPolicyID = policy?.id;
             if (mergeTransaction?.amount) {
                 updatedValues.taxAmount = convertToBackendAmount(calculateTaxAmount(transaction?.taxValue, mergeTransaction.amount, getCurrencyDecimals(getCurrency(transaction))));
    +        } else if (transaction?.taxAmount !== undefined) {
    +            // Amount is not yet resolved (still a conflict field); fall back to the transaction's own taxAmount
    +            // so the confirmation page displays the correct value. When the user resolves the amount conflict,
    +            // getMergeFieldUpdatedValues for 'amount' will recalculate taxAmount correctly.
    +            updatedValues.taxAmount = transaction.taxAmount;
             }
         }

    What alternative solutions did you explore? (Optional)

    An alternative would be to reorder the field processing loop so amount is always resolved before taxValue, but this is fragile and breaks the declarative nature of the merge field processing. Another option would be to defer taxAmount computation entirely to the confirmation step, but that would require more invasive changes across the merge flow. The fallback approach is the minimal, targeted fix.

  7. changed the title [-]Tax - Confirmation step doesn't show tax amount of A for scan expense[/-] [+][$250] Tax - Confirmation step doesn't show tax amount of A for scan expense[/+] on Apr 10, 2026
  8. melvin-bot commented on Apr 10, 2026

    @melvin-bot
  9. Ltbltbltbltb commented on Apr 10, 2026

    @Ltbltbltbltb

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  10. github-actions commented on Apr 10, 2026

    @github-actions
    Contributor

    ⚠️ @Ltbltbltbltb Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  11. Tony-MK commented on Apr 10, 2026

    @Tony-MK
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  12. github-actions commented on Apr 10, 2026

    @github-actions
    Contributor

    ⚠️ @Tony-MK Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  13. 25 remaining items

  14. changed the title [-][$250] Tax - Confirmation step doesn't show tax amount of A for scan expense[/-] [+][Due for payment 2026-04-30] [$250] Tax - Confirmation step doesn't show tax amount of A for scan expense[/+] on Apr 23, 2026
  15. melvin-bot commented on Apr 23, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  16. melvin-bot commented on Apr 23, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.61-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-04-30. 🎊

    For reference, here are some details about the assignees on this issue:

    • @dominictb does not require payment (Contractor)
  17. melvin-bot commented on Apr 23, 2026

    @melvin-bot

    @youssef-lr @dominictb The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  18. dominictb commented on Apr 24, 2026

    @dominictb
    Contributor

    Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions