Skip to content

[Due for payment 2026-03-31] Tax rate section does not appear when merging expenses after creating workspaces offline #85156

Closed

Description

@lanitochka17

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: 9.3.37-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #83587
Email or phone of affected tester (no customers): osidjnosndojnisonj@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go offline.
  3. Create two workspaces.
  4. Enable Taxes in both workspaces.
  5. Go to first workspace chat and create an expense with 0% tax rate.
  6. Go to second workspace chat and create an expense with 5% tax rate.
  7. Open the second expense.
  8. Click More > Merge.
  9. Select the first expense > Continue.

Expected Result:

Tax rate section will appear because both expenses have different tax rate.

Actual Result:

Tax rate section does not appear when merging expenses after creating workspaces offline.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7101653_1773358902043.3.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @dominictb

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 13, 2026
  2. melvin-bot commented on Mar 13, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #83587

  3. melvin-bot commented on Mar 13, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Mar 13, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. OSBotify commented on Mar 13, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #83587 - "[Merge] Merge tax rates v2" by @dominictb (High confidence)
    Related Issues: None

    Recommendation: REVERT

    This bug affects core merge functionality and blocks the feature from working as designed. The PR should be reverted to unblock the deploy.

    Labels: No label changes needed - keeping DeployBlockerCash as this is a frontend bug requiring an App PR fix/revert.

    Detailed Analysis

    Evidence

    PR #83587 added tax rate merging functionality. The bot correctly identified this PR as it was linked in the reproduction steps (#83587).

    The bug reproduces when:

    • Workspaces are created offline
    • Tax is enabled in both workspaces
    • User attempts to merge expenses with different tax rates

    Expected: Tax rate section should appear
    Actual: Tax rate section does not appear

    Verification

    The PR modifies src/libs/MergeTransactionUtils.ts, which contains the logic for determining which fields to show during merge operations.

    Key file modified: /home/runner/_work/App/App/src/libs/MergeTransactionUtils.ts
    Problematic code: Lines 231-234

    Root Cause

    The issue is in the getMergeableDataAndConflictFields function:

    // Temporarily skip merging tax value if either policy has tax tracking disabled
    if (field === taxValue && (!targetTransactionPolicy?.tax?.trackingEnabled || !sourceTransactionPolicy?.tax?.trackingEnabled)) {
        continue;
    }

    When workspaces are created offline:

    1. Policy objects may not be fully synchronized to Onyx yet
    2. The tax.trackingEnabled property may be undefined or incomplete
    3. The condition !targetTransactionPolicy?.tax?.trackingEnabled evaluates to true (because undefined is falsy)
    4. The code skips adding taxValue to the conflict fields array
    5. Result: No tax rate section appears in the merge UI, even though both workspaces have tax enabled

    The code works correctly when workspaces are created online (policies are fully synced), but fails in offline mode when policy data is incomplete or not yet persisted properly to Onyx.

  6. MelvinBot commented on Mar 13, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When workspaces are created offline and taxes are enabled on them, the tax rate section does not appear when merging two expenses that have different tax rates. Users expect to see a tax rate selector since the expenses have different tax rates (e.g., 0% vs 5%).

    What is the root cause of that problem?

    The guard at MergeTransactionUtils.ts:232 skips the taxValue field entirely when either policy's tax.trackingEnabled is falsy:

    if (field === 'taxValue' && (!targetTransactionPolicy?.tax?.trackingEnabled || !sourceTransactionPolicy?.tax?.trackingEnabled)) {
        continue;
    }

    For offline-created workspaces, the tax property is not included in the optimistic policy data generated by buildPolicyData (Policy.ts:2449-2557). The workspace creation uses Onyx.METHOD.SET which creates the full policy object, but the tax field is absent from that object.

    The tax.trackingEnabled property is only set when enablePolicyTaxes is called separately (Policy.ts:4692-4699), which uses Onyx.METHOD.MERGE to add tax: { trackingEnabled: true }.

    There are two scenarios that cause the tax data to be missing when the merge flow reads it:

    1. Draft-to-workspace conversion: If the workspace creation goes through createDraftWorkspace (Policy.ts:2953-3012) first, then the user enables taxes (MERGE), and then the workspace is finalized via createWorkspace (SET without tax data), the SET overwrites the previously-merged tax data.

    2. Missing optimistic data: The buildPolicyData function never includes the tax property. When the guard at line 232 checks policy?.tax?.trackingEnabled, policy.tax is undefined, making undefined?.trackingEnabled evaluate to undefined (falsy), which triggers the continue and skips the tax field.

    The merge flow loads policies from Onyx via useMergeTransactions (useMergeTransactions.ts:75-76), and passes them to getMergeableDataAndConflictFields in DetailsReviewPage (line 59-66). Since taxValue is never added to conflictFields, the tax rate section is never rendered.

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

    Include tax: { trackingEnabled: false } in the optimistic policy data in buildPolicyData (Policy.ts) and createDraftWorkspace, so the tax property always exists on policies. This ensures:

    • When enablePolicyTaxes MERGEs tax: { trackingEnabled: true }, it updates an existing property rather than relying on the MERGE to create a new nested object
    • The guard at MergeTransactionUtils.ts:232 correctly evaluates false (tax explicitly disabled) vs the current undefined (tax property missing)
    • If the workspace creation SET happens after a tax MERGE, the tax: { trackingEnabled: false } would be present but could be overridden by extracting the tax feature state from featuresMap (similar to how areDistanceRatesEnabled is already handled at line 2430)

    What alternative solutions did you explore? (Optional)

    An alternative would be to change the guard at MergeTransactionUtils.ts:232 to check for explicitly false rather than falsy:

    if (field === 'taxValue' && (targetTransactionPolicy?.tax?.trackingEnabled === false || sourceTransactionPolicy?.tax?.trackingEnabled === false)) {
        continue;
    }

    This would treat undefined (missing tax property) differently from false (explicitly disabled), allowing the tax section to appear when the tax property is simply missing. However, this is less robust because it changes the semantics for policies that genuinely don't have tax configured.


    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.

  7. dominictb commented on Mar 13, 2026

    @dominictb
    Contributor

    Checking

  8. self-assigned this
    on Mar 13, 2026
  9. 8 remaining items

  10. changed the title [-]Tax rate section does not appear when merging expenses after creating workspaces offline[/-] [+][Due for payment 2026-03-31] Tax rate section does not appear when merging expenses after creating workspaces offline[/+] on Mar 24, 2026
  11. melvin-bot commented on Mar 24, 2026

    @melvin-bot

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

  12. melvin-bot commented on Mar 24, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.42-3 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-03-31. 🎊

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

    • @dominictb does not require payment (Contractor)
  13. melvin-bot commented on Mar 24, 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]

  14. melvin-bot commented on Mar 24, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. dominictb commented on Mar 24, 2026

    @dominictb
    Contributor

    This will be paid centrally in merge project

  16. removed
    Awaiting PaymentAuto-added when associated PR is deployed to production
    on Mar 24, 2026
  17. dominictb commented on Mar 24, 2026

    @dominictb
    Contributor

    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.EngineeringWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions