You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-03-31] Expense - Tax rate section is missing when merging expenses when Reports tab is opened #85175
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):jsoidjsojniodnjiojs@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:
Go to staging.new.expensify.com
Create a new account.
Create two workspaces and enable Taxes for both workspaces.
Go to Reports tab (IMPORTANT).
Go to Inbox.
Go to workspace chat A.
Create an expense with 0% tax rate.
Go to workspace chat B.
Create an expense with 5% tax rate.
Open the expense (can be any from Step 7 or 9).
Click More > Merge.
Select the other expense > Continue.
Expected Result:
Tax rate section will be shown.
Actual Result:
Tax rate section is missing when merging expenses when Reports tab is opened.
👋 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:
Identify the pull request that introduced this issue and revert it.
Classification: Frontend bug Causing PR: #83587 - "[Merge] Merge tax rates v2" by @dominictb (High confidence) Related Issues: None
Recommendation: REVERT
The PR introduced a regression where tax rate section is missing when merging expenses outside of Search context (e.g., when navigating from Reports tab). This is a clear regression from the new tax merge functionality and reverting will restore the previous working state while the fix is developed.
Labels: No label changes made (keeping DeployBlockerCash as this is a frontend bug)
📋 Detailed Analysis
Evidence
The bug occurs specifically when:
User navigates from Reports tab (not Search tab)
Creates expenses with tax rates in workspace chats
Attempts to merge those expenses
The tax rate section appears when merging from Search tab but is missing when merging from Reports tab.
Root Cause
The issue is in the interaction between useMergeTransactions hook and SearchContext:
When policies are undefined, the expression undefined?.tax?.trackingEnabled evaluates to undefined (falsy), causing the entire tax field to be skipped.
Result: Tax rate section never appears in the merge UI when navigating from Reports tab.
Verification
Files affected by the bug:
src/hooks/useMergeTransactions.ts (lines 78-84) - Policy data not loaded outside search
src/libs/MergeTransactionUtils.ts (line 232) - Tax field skipped when policies undefined
Please re-state the problem that we are trying to solve in this issue.
When merging two expenses (from different workspaces with taxes enabled), the tax rate section is missing from the merge UI — but only when the user has navigated to the Reports tab before initiating the merge.
What is the root cause of that problem?
The root cause is that visiting the Reports tab causes stale search snapshot data to persist via usePreviousDefined, and the merge flow then shallow-merges that partial snapshot policy data over the full Onyx policy, destroying the tax configuration.
The chain of causation:
Search context persists after leaving the tab — SearchContext (src/components/Search/SearchContext.tsx:98) uses usePreviousDefined(queryParam) to preserve the last search query. When the user navigates away from the Reports tab, queryParam becomes undefined, but usePreviousDefined holds onto the Reports tab query. This keeps currentSearchHash set to the Reports tab hash and currentSearchResults pointing to the Reports tab snapshot (loaded via useOnyx at line 116).
Merge flow unconditionally merges snapshot data — In useMergeTransactions (src/hooks/useMergeTransactions.ts:78-84), the guard currentSearchHash && currentSearchResults?.data passes even when the user is no longer on the Search screen, because both values persist from the Reports tab visit.
Shallow spread overwrites nested policy data — mergePolicyWithSearchSnapshot (src/hooks/useMergeTransactions.ts:25-38) does {...onyxPolicy, ...snapshotPolicy}. Search snapshots are known to contain partial policy data (confirmed by a comment at src/components/SelectionListWithSections/Search/TransactionListItem.tsx:81: "Fetch policy categories directly from Onyx since they are not included in the search snapshot"). If the snapshot policy includes a tax key with incomplete data (e.g., tax: {} or tax without trackingEnabled), the shallow spread replaces the full Onyx tax object, losing trackingEnabled: true.
Tax section is gated on policy data — At src/libs/MergeTransactionUtils.ts:232, the condition !targetTransactionPolicy?.tax?.trackingEnabled || !sourceTransactionPolicy?.tax?.trackingEnabled evaluates to true when the policy's tax.trackingEnabled is missing/falsy, causing the entire taxValue field to be skipped with continue. The tax rate section never appears in the merge UI.
Why it only happens after visiting the Reports tab: Without visiting the Reports tab, currentSearchResults is undefined (no search snapshot fetched), so the guard at line 78 fails and mergePolicyWithSearchSnapshot is never called. The full Onyx policy (with tax.trackingEnabled: true) is used directly, and the tax section renders correctly.
What changes do you think we should make in order to solve the problem?
Fix mergePolicyWithSearchSnapshot in src/hooks/useMergeTransactions.ts to not overwrite existing Onyx policy data with partial snapshot data. The snapshot should only be used as a fallback when Onyx data is missing:
This preserves the intent of using snapshot data when the Onyx policy is unavailable (e.g., during search-initiated merge), while preventing partial snapshot data from overwriting the complete Onyx policy.
What alternative solutions did you explore? (Optional)
Deep merge for the tax field specifically — e.g., return { ...onyxPolicy, ...snapshotPolicy, tax: { ...onyxPolicy?.tax, ...snapshotPolicy?.tax } }. More targeted but introduces complexity and doesn't prevent similar issues with other nested policy fields in the future.
Only apply snapshot merge when on the Search screen — Add a check like focusedScreenName === SCREENS.SEARCH.ROOT to the guard condition. This would work but would also break the snapshot fallback for merge flows initiated from within search results.
Clear currentSearchHash when leaving the Search screen — Would require changing the usePreviousDefined behavior, which could break other search-dependent features that rely on the preserved query (e.g., returning to the last search results).
The recommended fix (using ?? instead of spread) is the simplest and safest approach since the comment on line 24 states "Both Onyx and snapshot data can be stale, merging them to maintain freshness", but in practice, when both exist, the Onyx policy is the more complete data source and should take precedence.
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.
We're prioritizing snapshot data over onyx data for transaction and snapshot data might not always include taxValue.
@youssef-lr@hoangzinh Do you remember why you added that in the Phase 2 PR? Should we only use snapshot data if we're on search? Should we merge snapshot and onyx like what we did with policies here?
changed the title [-]Expense - Tax rate section is missing when merging expenses when Reports tab is opened[/-][+][Due for payment 2026-03-31] Expense - Tax rate section is missing when merging expenses when Reports tab is opened[/+]on Mar 24, 2026
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:
@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]
Activity
melvin-bot commentedon Mar 13, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #83587
melvin-bot commentedon Mar 13, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Mar 13, 2026
👋 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:
OSBotify commentedon Mar 13, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #83587 - "[Merge] Merge tax rates v2" by @dominictb (High confidence)
Related Issues: None
Recommendation: REVERT
The PR introduced a regression where tax rate section is missing when merging expenses outside of Search context (e.g., when navigating from Reports tab). This is a clear regression from the new tax merge functionality and reverting will restore the previous working state while the fix is developed.
Labels: No label changes made (keeping DeployBlockerCash as this is a frontend bug)
📋 Detailed Analysis
Evidence
The bug occurs specifically when:
The tax rate section appears when merging from Search tab but is missing when merging from Reports tab.
Root Cause
The issue is in the interaction between
useMergeTransactionshook andSearchContext:Line 78 in
src/hooks/useMergeTransactions.ts:This condition checks if the user is on a search page before fetching policy data from search results.
When NOT on Search tab:
currentSearchHashis-1(default value from SearchContext line 111)false(since-1is falsy in JavaScript)targetTransactionPolicyandsourceTransactionPolicy) remainsundefinedLine 232 in
src/libs/MergeTransactionUtils.ts:When policies are
undefined, the expressionundefined?.tax?.trackingEnabledevaluates toundefined(falsy), causing the entire tax field to be skipped.Result: Tax rate section never appears in the merge UI when navigating from Reports tab.
Verification
Files affected by the bug:
src/hooks/useMergeTransactions.ts(lines 78-84) - Policy data not loaded outside searchsrc/libs/MergeTransactionUtils.ts(line 232) - Tax field skipped when policies undefinedConfirmed PR modifies these files:
src/hooks/useMergeTransactions.ts- Added policy loading logicsrc/libs/MergeTransactionUtils.ts- Added tax merge logic with policy checkTimeline alignment:
The bug is a direct result of PR #83587's new policy-dependent tax merge logic not accounting for non-search navigation contexts.
MelvinBot commentedon Mar 13, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When merging two expenses (from different workspaces with taxes enabled), the tax rate section is missing from the merge UI — but only when the user has navigated to the Reports tab before initiating the merge.
What is the root cause of that problem?
The root cause is that visiting the Reports tab causes stale search snapshot data to persist via
usePreviousDefined, and the merge flow then shallow-merges that partial snapshot policy data over the full Onyx policy, destroying thetaxconfiguration.The chain of causation:
Search context persists after leaving the tab —
SearchContext(src/components/Search/SearchContext.tsx:98) usesusePreviousDefined(queryParam)to preserve the last search query. When the user navigates away from the Reports tab,queryParambecomesundefined, butusePreviousDefinedholds onto the Reports tab query. This keepscurrentSearchHashset to the Reports tab hash andcurrentSearchResultspointing to the Reports tab snapshot (loaded viauseOnyxat line 116).Merge flow unconditionally merges snapshot data — In
useMergeTransactions(src/hooks/useMergeTransactions.ts:78-84), the guardcurrentSearchHash && currentSearchResults?.datapasses even when the user is no longer on the Search screen, because both values persist from the Reports tab visit.Shallow spread overwrites nested policy data —
mergePolicyWithSearchSnapshot(src/hooks/useMergeTransactions.ts:25-38) does{...onyxPolicy, ...snapshotPolicy}. Search snapshots are known to contain partial policy data (confirmed by a comment atsrc/components/SelectionListWithSections/Search/TransactionListItem.tsx:81: "Fetch policy categories directly from Onyx since they are not included in the search snapshot"). If the snapshot policy includes ataxkey with incomplete data (e.g.,tax: {}ortaxwithouttrackingEnabled), the shallow spread replaces the full Onyxtaxobject, losingtrackingEnabled: true.Tax section is gated on policy data — At
src/libs/MergeTransactionUtils.ts:232, the condition!targetTransactionPolicy?.tax?.trackingEnabled || !sourceTransactionPolicy?.tax?.trackingEnabledevaluates totruewhen the policy'stax.trackingEnabledis missing/falsy, causing the entiretaxValuefield to be skipped withcontinue. The tax rate section never appears in the merge UI.Why it only happens after visiting the Reports tab: Without visiting the Reports tab,
currentSearchResultsisundefined(no search snapshot fetched), so the guard at line 78 fails andmergePolicyWithSearchSnapshotis never called. The full Onyx policy (withtax.trackingEnabled: true) is used directly, and the tax section renders correctly.What changes do you think we should make in order to solve the problem?
Fix
mergePolicyWithSearchSnapshotinsrc/hooks/useMergeTransactions.tsto not overwrite existing Onyx policy data with partial snapshot data. The snapshot should only be used as a fallback when Onyx data is missing:This preserves the intent of using snapshot data when the Onyx policy is unavailable (e.g., during search-initiated merge), while preventing partial snapshot data from overwriting the complete Onyx policy.
What alternative solutions did you explore? (Optional)
Deep merge for the
taxfield specifically — e.g.,return { ...onyxPolicy, ...snapshotPolicy, tax: { ...onyxPolicy?.tax, ...snapshotPolicy?.tax } }. More targeted but introduces complexity and doesn't prevent similar issues with other nested policy fields in the future.Only apply snapshot merge when on the Search screen — Add a check like
focusedScreenName === SCREENS.SEARCH.ROOTto the guard condition. This would work but would also break the snapshot fallback for merge flows initiated from within search results.Clear
currentSearchHashwhen leaving the Search screen — Would require changing theusePreviousDefinedbehavior, which could break other search-dependent features that rely on the preserved query (e.g., returning to the last search results).The recommended fix (using
??instead of spread) is the simplest and safest approach since the comment on line 24 states "Both Onyx and snapshot data can be stale, merging them to maintain freshness", but in practice, when both exist, the Onyx policy is the more complete data source and should take precedence.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.dominictb commentedon Mar 13, 2026
Culprit is here:
App/src/hooks/useMergeTransactions.ts
Line 55 in 9a73171
We're prioritizing snapshot data over onyx data for transaction and snapshot data might not always include
taxValue.@youssef-lr @hoangzinh Do you remember why you added that in the Phase 2 PR? Should we only use snapshot data if we're on search? Should we merge snapshot and onyx like what we did with policies here?
hoangzinh commentedon Mar 13, 2026
It was YES that time because we're on the search page.
12 remaining items
[-]Expense - Tax rate section is missing when merging expenses when Reports tab is opened[/-][+][Due for payment 2026-03-31] Expense - Tax rate section is missing when merging expenses when Reports tab is opened[/+]melvin-bot commentedon Mar 24, 2026
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Mar 24, 2026
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:
melvin-bot commentedon Mar 24, 2026
@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]
melvin-bot commentedon Mar 24, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)dominictb commentedon Mar 24, 2026
Fixed. This will be paid centrally in merge project