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-04-14] Expense - Selection mode persists after undeleting all expenses offline #86790
Version Number: 9.3.51-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:#85818 Email or phone of affected tester (no customers):snodijosdnjoijiosnj@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: iPhone 15 Pro Max / iOS 26.3 App Component: Search
Action Performed:
Launch Expensify app.
Go to workspace chat.
Create an expense.
Delete the expense.
Go to Reports > Expenses.
Click Status, select Deleted and click Apply.
Go offline.
Long tap on the expense > Select.
Tap dropdown button > Undelete.
Expected Result:
Selection mode will exit because there is no more expense.
Actual Result:
Selection mode persists after undeleting all expenses offline.
👋 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: #85818 - "Deleted transactions on search" by @jnowakow (High confidence) Related Issues: None
Recommendation: REVERT
PR #85818 introduced the undelete functionality for deleted transactions in search. However, it has a bug in the offline flow where the selection mode persists after undeleting all expenses, even though the expenses are no longer visible in the list.
When undelete is performed offline, the following sequence occurs:
Line 729 in useSearchBulkActions.ts: undeleteTransactions(selectedTransactionsKeys) is called
This optimistically changes each transaction's reportID from -1 (TRASH_REPORT_ID) to the self DM report ID
Line 730: clearSelectedTransactions() is called immediately after
The bug: The transactions are optimistically updated and no longer match the "deleted" filter, so they disappear from the list. However, the selected transactions state is not properly cleared, causing selection mode to persist even though there are 0 visible items.
In src/components/Search/index.tsx (lines 344-356), there is a useEffect that should turn off selection mode when selectedKeys.length === 0, but this condition is not met because the selection wasn't fully cleared.
The issue is specific to the offline scenario because:
When online, the backend response likely triggers a search results refresh that clears the stale selected items
When offline, the optimistic updates change the transactions but the selection state cleanup doesn't complete properly before the re-render
There are two issues causing selection mode to persist after undeleting all expenses offline:
1. shouldTurnOffSelectionMode flag is not set for undelete. In useSearchBulkActions.ts:729-730, the undelete handler calls clearSelectedTransactions() without passing shouldTurnOffSelectionMode = true. The effect in Search/index.tsx:344-356 that exits mobile selection mode requires all three conditions: no selected transactions, selection mode enabled, AND shouldTurnOffSelectionMode === true. The third condition fails because the default is false.
2. The search snapshot is not updated by undelete.changeTransactionsReport (called via useUndeleteTransactions) optimistically updates ONYXKEYS.COLLECTION.TRANSACTION (changing reportID from TRASH_REPORT_ID to the new report), but does NOT update ONYXKEYS.COLLECTION.SNAPSHOT — confirmed by the type annotation in Transaction.ts:888-898. The search UI reads from the snapshot, so items remain visible in the "Deleted" filter. This means the fallback mechanism at Search/index.tsx:845-850 (exit selection mode when results become empty) also never fires.
What changes do you think we should make in order to solve the problem?
Pass shouldTurnOffSelectionMode = true to clearSelectedTransactions() in the undelete handler in useSearchBulkActions.ts. This mirrors how export actions already pass this flag and will cause the effect in Search/index.tsx to properly exit mobile selection mode after undelete clears the selection.
Additionally, the search snapshot should be optimistically updated when undeleting transactions, similar to how submit/approve/pay actions handle snapshot updates in Search.ts:603-612. This would ensure the undeleted items properly disappear from the "Deleted" filter view while offline, and would also enable the empty-results fallback to fire correctly.
What alternative solutions did you explore? (Optional)
An alternative would be to only fix the shouldTurnOffSelectionMode flag without updating the snapshot. This would exit selection mode but leave the undeleted items visually present in the "Deleted" filter until the next server re-fetch — a less complete but simpler fix. Given this is a deploy blocker, the shouldTurnOffSelectionMode fix alone may be sufficient as a quick fix, with the snapshot update as a follow-up.
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.
changed the title [-]Expense - Selection mode persists after undeleting all expenses offline[/-][+][Due for payment 2026-04-14] Expense - Selection mode persists after undeleting all expenses offline[/+]on Apr 7, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.52-9 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@luacmartins@jakubstec 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 31, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #85818
melvin-bot commentedon Mar 31, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Mar 31, 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 31, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #85818 - "Deleted transactions on search" by @jnowakow (High confidence)
Related Issues: None
Recommendation: REVERT
PR #85818 introduced the undelete functionality for deleted transactions in search. However, it has a bug in the offline flow where the selection mode persists after undeleting all expenses, even though the expenses are no longer visible in the list.
Labels: Keeping
DeployBlockerCash(App deploy blocked - frontend bug requires App PR fix)📋 Detailed Analysis
Evidence
Verification
PR #85818 modifies the following key files related to this bug:
src/hooks/useSearchBulkActions.ts- Added undelete action handler (lines 719-733)src/hooks/useUndeleteTransactions.ts- New hook that callschangeTransactionsReportsrc/libs/actions/Transaction.ts- ModifiedchangeTransactionsReportto handle deleted transactionssrc/components/Search/index.tsx- Selection mode management logicRoot Cause
When undelete is performed offline, the following sequence occurs:
Line 729 in
useSearchBulkActions.ts:undeleteTransactions(selectedTransactionsKeys)is calledreportIDfrom-1(TRASH_REPORT_ID) to the self DM report IDLine 730:
clearSelectedTransactions()is called immediately afterThe bug: The transactions are optimistically updated and no longer match the "deleted" filter, so they disappear from the list. However, the selected transactions state is not properly cleared, causing selection mode to persist even though there are 0 visible items.
In
src/components/Search/index.tsx(lines 344-356), there is auseEffectthat should turn off selection mode whenselectedKeys.length === 0, but this condition is not met because the selection wasn't fully cleared.The issue is specific to the offline scenario because:
MelvinBot commentedon Mar 31, 2026
Proposal
What is the root cause of that problem?
There are two issues causing selection mode to persist after undeleting all expenses offline:
1.
shouldTurnOffSelectionModeflag is not set for undelete. InuseSearchBulkActions.ts:729-730, the undelete handler callsclearSelectedTransactions()without passingshouldTurnOffSelectionMode = true. The effect inSearch/index.tsx:344-356that exits mobile selection mode requires all three conditions: no selected transactions, selection mode enabled, ANDshouldTurnOffSelectionMode === true. The third condition fails because the default isfalse.2. The search snapshot is not updated by undelete.
changeTransactionsReport(called viauseUndeleteTransactions) optimistically updatesONYXKEYS.COLLECTION.TRANSACTION(changingreportIDfromTRASH_REPORT_IDto the new report), but does NOT updateONYXKEYS.COLLECTION.SNAPSHOT— confirmed by the type annotation inTransaction.ts:888-898. The search UI reads from the snapshot, so items remain visible in the "Deleted" filter. This means the fallback mechanism atSearch/index.tsx:845-850(exit selection mode when results become empty) also never fires.What changes do you think we should make in order to solve the problem?
Pass
shouldTurnOffSelectionMode = truetoclearSelectedTransactions()in the undelete handler inuseSearchBulkActions.ts. This mirrors how export actions already pass this flag and will cause the effect inSearch/index.tsxto properly exit mobile selection mode after undelete clears the selection.Additionally, the search snapshot should be optimistically updated when undeleting transactions, similar to how submit/approve/pay actions handle snapshot updates in
Search.ts:603-612. This would ensure the undeleted items properly disappear from the "Deleted" filter view while offline, and would also enable the empty-results fallback to fire correctly.What alternative solutions did you explore? (Optional)
An alternative would be to only fix the
shouldTurnOffSelectionModeflag without updating the snapshot. This would exit selection mode but leave the undeleted items visually present in the "Deleted" filter until the next server re-fetch — a less complete but simpler fix. Given this is a deploy blocker, theshouldTurnOffSelectionModefix alone may be sufficient as a quick fix, with the snapshot update as a follow-up.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.12 remaining items
luacmartins commentedon Apr 2, 2026
We probably should
trjExpensify commentedon Apr 2, 2026
Yeah, if it's doable we should. 👍
[-]Expense - Selection mode persists after undeleting all expenses offline[/-][+][Due for payment 2026-04-14] Expense - Selection mode persists after undeleting all expenses offline[/+]melvin-bot commentedon Apr 7, 2026
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Apr 7, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.52-9 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-14. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Apr 7, 2026
@luacmartins @jakubstec 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 Apr 7, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)