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 2025-12-17] [$250] Reports - Device back button redirects to previous section but selection mode remains. #74585
Version Number: 9.2.46-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:#70877 Email or phone of affected tester (no customers):ibellicotest+2022@gmail.com Issue reported by: Applause Internal Team Device used: Motorola MotoG60 / Android 12 / Chrome ( mWeb) - Windows 11 / Chrome App Component: Search
Action Performed:
Prerequisite: Account has at least one workspace.
Prerequisite 2: Delayed submissions enabled.
Open the staging.new.expensify.com website.
Open any workspace chat.
Create a manual expense or empty report.
Navigate to "Reports" > "Submit" and from there to "Reports" > "Reports"
Select the just created expense.
Use device back button.
Note that you land on "Submit" again and expense is still selected.
Expected Result:
When using back button during selection mode, expense shouldn´t be displayed selected anymore and user should remain on the same section.
Actual Result:
When using back button during selection mode, user lands on previous section and expense is still selected.
Please re-state the problem that we are trying to solve in this issue.
When pressing the back button while items are selected in Reports search, the user navigates to the previous section (e.g., "Reports" to "Submit"), but selections remain visible and mobile selection mode stays enabled on mWeb platforms.
What is the root cause of that problem?
The cleanup effect that clears selections early returns when navigating between search pages:
When navigating from "Reports" to "Submit" (both are search pages), isSearchTopmostFullScreenRoute() returns true for both, so the cleanup is skipped and selections persist.
Additionally, the back button handler only works on Android native, not mWeb:
This clears selections and turns off mobile selection mode when navigating between different search pages, fixing both the original issue and mWeb behavior.
What alternative solutions did you explore? (Optional)
Prevent selection restoration:
Add hash check at selection restoration effect to prevent restoring with stale data. However, this doesn't turn off mobile selection mode.
Implement web back button handler:
Add History API handling to useHandleBackButton for web. More complex and fragile than using existing cleanup effect.
We also need to prevent enable mobile selection mode while the hash is updating
if (currentSearchHash !== hash) {
return;
}
Screen_Recording_2025-11-24_at_23.28.48.mov
What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
🚨 Edited by proposal-police: This proposal was edited at 2025-11-24 16:52:55 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Reports - Device back button redirects to previous section but selection mode remains.
What is the root cause of that problem?
We already have a logic to reset selection and mobile selection mode when focus is lost from search page but it early returns if we are currently on search route
so when we go back to another search page with different hash it early returns from resetting the selection
What changes do you think we should make in order to solve the problem?
We should also make sure that the hash is the same as the currentSearchHash in addition to isSearchTopmostFullScreenRoute so that we reset whenever the search query is changed while we are on search page
if (isSearchTopmostFullScreenRoute() && currentSearchHash === hash) {
return;
}
For mWeb, there is another bug that wrongly re-enables the mobile selection mode. It is caused by this effect below
When we clear the selection and turn off mobile mode here the mobile selection mode value (from onyx) gets updated before the selectedTransactions is cleared so the effect above turnOnMobileSelectionMode because selectedKeys is not empty while isMobileSelectionModeEnabled is false.
Solution: this effect is needed only when the screen width changes to either turn on or off the selection mode as needed so the dependency should only be
changed the title [-]Reports - Device back button redirects to previous section but selection mode remains.[/-][+][$250] Reports - Device back button redirects to previous section but selection mode remains.[/+]on Nov 18, 2025
If this GH needs attention or action during that time period, please reapply the BugZero label to assign someone to help out, but leave me assigned as well. Alternatively, you can post in Slack for a BZ buddy to take action.
Otherwise, I will catch up on issues that need attention when I get back.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Activity
melvin-bot commentedon Nov 7, 2025
Triggered auto assignment to @strepanier03 (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.TaduJR commentedon Nov 7, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
When pressing the back button while items are selected in Reports search, the user navigates to the previous section (e.g., "Reports" to "Submit"), but selections remain visible and mobile selection mode stays enabled on mWeb platforms.
What is the root cause of that problem?
The cleanup effect that clears selections early returns when navigating between search pages:
App/src/components/Search/index.tsx
Lines 583 to 592 in 4692a45
When navigating from "Reports" to "Submit" (both are search pages),
isSearchTopmostFullScreenRoute()returnstruefor both, so the cleanup is skipped and selections persist.Additionally, the back button handler only works on Android native, not mWeb:
Android:
App/src/hooks/useHandleBackButton/index.android.ts
Lines 6 to 13 in 4692a45
mWeb (no-op):
App/src/hooks/useHandleBackButton/index.ts
Line 6 in 4692a45
On mWeb, browser back navigation happens without clearing selections.
What changes do you think we should make in order to solve the problem?
Add hash comparison to the cleanup effect so it only skips for the same search page.
Step 1: Add
currentSearchHashto destructured variablesApp/src/components/Search/index.tsx
Lines 243 to 257 in 4692a45
Add
currentSearchHashas the first property in the destructuring at line 244:Step 2: Update cleanup effect
App/src/components/Search/index.tsx
Lines 583 to 592 in 4692a45
Change line 585 from:
To:
Also update line 591 dependencies from:
To:
This clears selections and turns off mobile selection mode when navigating between different search pages, fixing both the original issue and mWeb behavior.
What alternative solutions did you explore? (Optional)
Prevent selection restoration:
Add hash check at selection restoration effect to prevent restoring with stale data. However, this doesn't turn off mobile selection mode.
Implement web back button handler:
Add History API handling to
useHandleBackButtonfor web. More complex and fragile than using existing cleanup effect.daledah commentedon Nov 7, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
When using back button during selection mode, user lands on previous section and expense is still selected.
What is the root cause of that problem?
App/src/components/Search/index.tsx
Line 542 in 73a784d
setSelectedTransactionswith theselectedTransactionsfromuseSearchContextApp/src/components/Search/index.tsx
Line 524 in 73a784d
at this time,
selectedTransactionshasn't been cleared yet soselectedTransactionswill be preservedWhat changes do you think we should make in order to solve the problem?
setSelectedTransactionsif the data is still clearing. To do that we can add this checkin
App/src/components/Search/index.tsx
Line 436 in 73a784d
This way will make sure the
selectedTransactionsused in this hook is up to date.Clear the mobile selection mode like we did in
App/src/components/MoneyReportHeader.tsx
Lines 1294 to 1299 in ae86bcb
Then in
App/src/components/Search/index.tsx
Line 457 in ae86bcb
We also need to prevent enable mobile selection mode while the hash is updating
Screen_Recording_2025-11-24_at_23.28.48.mov
What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
FitseTLT commentedon Nov 7, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-11-24 16:52:55 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Reports - Device back button redirects to previous section but selection mode remains.
What is the root cause of that problem?
We already have a logic to reset selection and mobile selection mode when focus is lost from search page but it early returns if we are currently on search route
App/src/components/Search/index.tsx
Lines 538 to 545 in 0be1450
so when we go back to another search page with different hash it early returns from resetting the selection
What changes do you think we should make in order to solve the problem?
We should also make sure that the
hashis the same as thecurrentSearchHashin addition toisSearchTopmostFullScreenRouteso that we reset whenever the search query is changed while we are on search pageFor mWeb, there is another bug that wrongly re-enables the mobile selection mode. It is caused by this effect below
App/src/components/Search/index.tsx
Lines 371 to 376 in 18c34ce
When we clear the selection and turn off mobile mode here the mobile selection mode value (from onyx) gets updated before the
selectedTransactionsis cleared so the effect aboveturnOnMobileSelectionModebecauseselectedKeysis not empty whileisMobileSelectionModeEnabledis false.Solution: this effect is needed only when the screen width changes to either turn on or off the selection mode as needed so the dependency should only be
App/src/components/Search/index.tsx
Line 375 in 18c34ce
What alternative solutions did you explore? (Optional)
melvin-bot commentedon Nov 12, 2025
@strepanier03 Eep! 4 days overdue now. Issues have feelings too...
melvin-bot commentedon Nov 15, 2025
@strepanier03 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
melvin-bot commentedon Nov 18, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021990620962377833114
[-]Reports - Device back button redirects to previous section but selection mode remains.[/-][+][$250] Reports - Device back button redirects to previous section but selection mode remains.[/+]45 remaining items
strepanier03 commentedon Dec 18, 2025
Payment Summary
strepanier03 commentedon Dec 18, 2025
HEADS UP
I am OoO starting 12-19 and will return on 12-29.
If this GH needs attention or action during that time period, please reapply the
BugZerolabel to assign someone to help out, but leave me assigned as well. Alternatively, you can post in Slack for a BZ buddy to take action.Otherwise, I will catch up on issues that need attention when I get back.
Krishna2323 commentedon Dec 23, 2025
Will complete the checklist today.
melvin-bot commentedon Dec 23, 2025
@strepanier03 Huh... This is 4 days overdue. Who can take care of this?
melvin-bot commentedon Dec 25, 2025
@strepanier03 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
Krishna2323 commentedon Dec 26, 2025
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: [Search] Move selectedTransactions array to SearchContext #46406 (comment)
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/582796
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-0627-a256-b777-0bf7d2bbf824strepanier03 commentedon Dec 30, 2025
Reg test is made and I removed the hold from the payment summary. Thanks @Krishna2323, closing out.
Krishna2323 commentedon Jan 17, 2026
Requested in ND.
twisterdotcom commentedon Jan 18, 2026
@Krishna2323 has submitted payment for this report on ND here.
SO: https://stackoverflowteams.com/c/expensify/questions/7582
Zapier Logs
Run ID: 00040eee-7899-a014-a757-30172330e5f4