Skip to content

[Due for payment 2026-04-14] Expense - Selection mode persists after undeleting all expenses offline #86790

Closed

Description

@mitarachim

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

  1. Launch Expensify app.
  2. Go to workspace chat.
  3. Create an expense.
  4. Delete the expense.
  5. Go to Reports > Expenses.
  6. Click Status, select Deleted and click Apply.
  7. Go offline.
  8. Long tap on the expense > Select.
  9. 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.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7118370_1774987727003.ScreenRecording_04-01-2026_04-07-47_1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @jakubstec

Activity

  1. added
    DeployBlockerCash
    Daily
    Bug
    DeployBlocker
    on Mar 31, 2026
  2. melvin-bot commented on Mar 31, 2026

    @melvin-bot

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

  3. melvin-bot commented on Mar 31, 2026

    @melvin-bot

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

  4. github-actions commented on Mar 31, 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. removed
    DeployBlocker
    on Mar 31, 2026
  6. OSBotify commented on Mar 31, 2026

    @OSBotify
    Contributor

    🔍 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 calls changeTransactionsReport
    • src/libs/actions/Transaction.ts - Modified changeTransactionsReport to handle deleted transactions
    • src/components/Search/index.tsx - Selection mode management logic

    Root Cause

    When undelete is performed offline, the following sequence occurs:

    1. 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
    2. Line 730: clearSelectedTransactions() is called immediately after

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

    4. 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
  7. MelvinBot commented on Mar 31, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    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.

  8. 12 remaining items

  9. luacmartins commented on Apr 2, 2026

    @luacmartins
    Contributor

    We probably should

  10. trjExpensify commented on Apr 2, 2026

    @trjExpensify
    Contributor

    Yeah, if it's doable we should. 👍

  11. added
    Weekly
    Awaiting Payment
    and removed
    Hourly
    on Apr 7, 2026
  12. 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
  13. melvin-bot commented on Apr 7, 2026

    @melvin-bot

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

  14. removed
    Reviewing
    on Apr 7, 2026
  15. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    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:

    • @jakubstec does not require payment (Contractor)
  16. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    @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]

  17. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  18. added
    Reviewing
    Weekly
    and removed
    Weekly
    on Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugEngineeringReviewingWeekly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions