Skip to content

[Due for payment 2026-05-20] Spend - Search results appear after resetting filter, navigating to a different tab and back #90073

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.69-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/folder/13176922/test-cases/41237516
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: MacBook Air 15.7.4 Chrome, iPhone 15 iOS 26.3.1
App Component: Search

Action Performed:

  1. Sign in to ND
  2. Create a workspace, add a couple of expenses
  3. Navigate to Spend tab/ Expenses
  4. In the search field type merchant:[anything with no results], apply the filter
  5. Click on the expand button on filter chip, click "Reset"
  6. Open Workspaces tab
  7. Open Spend tab

Expected Result:

Full expenses list is displayed, filter chip does not appear on the page

Actual Result:

After resetting the filter and navigating to a different tab, then back to Spend/ Expenses, the filter and the results appear again on the page

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7148603_1778262100620.Nothing_to_show_adre_resetting_filter.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @dmkt9

Activity

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

    @melvin-bot

    Triggered auto assignment to @yuwenmemon (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  3. melvin-bot commented on May 8, 2026

    @melvin-bot

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

  4. github-actions commented on May 8, 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 May 8, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: Could not be identified with high confidence — see Detailed Analysis below
    Related Issues: Similar to #89013 (previously fixed by #89082)

    Recommendation: NEEDS INVESTIGATION

    The filter chip reappearing after Reset + tab navigation is a known fragile area of the codebase. The fix in PR #89082 (module-level lastSyncedQuerySig in useSearchFilterSync) addressed the same class of bug, but the current report suggests a surviving or re-introduced edge case. The root cause requires hands-on reproduction by someone familiar with the Search filter sync mechanism.

    Assigned: @wildan-m (author of PR #88246, the only staging-cycle PR that modifies useSearchFiltersBar.tsx), @joekaufmanexpensify, @dmkt9 (approvers of PR #88246)
    Labels: DeployBlockerCash label kept — this is a staging-only, App-side bug affecting a core Search UX flow. No label changes made.

    Detailed Analysis

    Evidence

    Bug Summary: After applying a merchant:[no-results] filter via the search input, expanding the filter chip's dropdown popup, and clicking Reset inside the popup, the filter chip initially disappears. However, after navigating to the Workspaces tab and returning to Spend/Expenses, the filter chip and filtered (empty) results reappear.

    Platform: iOS native and Windows/Chrome (staging only, not production).

    Affected code path:

    1. SearchAdvancedFiltersButton calls useSearchFilterSync(queryJSON, filterFormValues) which syncs the URL-derived queryJSON into the Onyx SEARCH_ADVANCED_FILTERS_FORM key.
    2. useSearchFiltersBar reads from Onyx SEARCH_ADVANCED_FILTERS_FORM to render filter chips.
    3. Resetting a filter chip opens a popup (CommonPopup, TextInputPopup, etc.) and clicking Reset calls updateFilterForm({[filterKey]: undefined}) via useUpdateFilterQuery(queryJSON, true), which calls close(() => Navigation.setParams({q: updatedQueryString})).
    4. useSearchFilterSync uses a module-level lastSyncedQuerySig to prevent redundant syncs on remount.

    Why the filter reappears: When the user navigates back to Spend from Workspaces, the Search screen unfreezes. SearchActionsBarSwitch transitions from showStatic=true to showStatic=false (via startTransition + useFocusEffect), which remounts SearchAdvancedFiltersButton. useSearchFilterSync fires its effect. If the URL q param at this point still contains merchant:foo (because the Navigation.setParams callback was delayed, lost, or the navigation framework restored the old params on tab switch), then querySig for merchant:foo differs from lastSyncedQuerySig (which was updated to the reset value), causing updateAdvancedFilters to write the merchant filter back into Onyx — making the chip reappear.

    Verification

    • Affected files: src/hooks/useSearchFilterSync.ts, src/components/Search/SearchPageHeader/useSearchFiltersBar.tsx, src/components/Search/hooks/useUpdateFilterQuery.tsx
    • PR Add withdrawal-status search filter #88246 (in staging) modifies useSearchFiltersBar.tsx by adding FILTER_KEYS.WITHDRAWAL_STATUS handling. It also adds a new filter that goes through the same reset code paths. While this PR is unlikely to be the direct cause, it is the only staging-cycle PR touching the search filter bar.
    • The tab navigator uses freezeOnBlur: true (src/libs/Navigation/AppNavigator/Navigators/TabNavigator.tsx). When the user returns to Spend, the screen unfreezes and isHeaderInteractive transitions from false to true via startTransition, remounting SearchAdvancedFiltersButton.

    Root Cause

    The most probable root cause is a race condition or navigation state issue: after the user clicks Reset in the filter chip popup, the Navigation.setParams({q: defaultQuery}) call (deferred through the Modal close() callback) either races with or loses to the tab navigation, leaving the URL q param set to the old merchant:foo value. When the user returns to Spend, useSearchFilterSync sees the stale merchant:foo URL and writes it back to Onyx.

    The lastSyncedQuerySig module-level variable (introduced by PR #89082) is the right mechanism but only works correctly if the URL update successfully propagates before any refocus-triggered sync.

    Suggested next steps:

    1. Reproduce the bug and log the value of q param when the screen regains focus after the tab switch.
    2. Verify whether Navigation.setParams fires correctly after the popup Reset on iOS/Chrome.
    3. Consider resetting lastSyncedQuerySig (or nullifying it) when clearAdvancedFilters or popup reset is called, so the next focus-triggered sync always re-evaluates from the URL — regardless of whether the URL update raced with navigation.
  6. MelvinBot commented on May 8, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    When a filter is reset, the URL q param updates correctly, but saveLastSearchParams is skipped because the default query's snapshot data was already loaded from the user's initial visit (before any filter was applied). The guard if (isSnapshotDataLoaded || isSnapshotSearchLoading) { return; } short-circuits both search() and saveLastSearchParams(), so the Onyx key REPORT_NAVIGATION_LAST_SEARCH_QUERY retains the old filtered query.

    When the user navigates to a different tab, cleanPreservedNavigatorStates deletes the search navigator's preserved state (since it's nested inside TAB_NAVIGATOR, not at the root level). When the user returns to the Spend tab, SearchTabButton.navigateToSearch tries getLastRoute() first (returns undefined since preserved state was cleaned), then falls back to the stale lastSearchParams from Onyx — restoring the old filter.

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

    In useSearchPageSetup.ts, saveLastSearchParams should be called unconditionally (outside the early-return guard), so that any query change — including one where the snapshot is already loaded — still updates REPORT_NAVIGATION_LAST_SEARCH_QUERY in Onyx. The search() API call can remain gated behind isSnapshotDataLoaded since there's no need to re-fetch already-loaded data, but saving the last search params is always necessary to keep tab restoration in sync with the current URL.

    Move saveLastSearchParams(...) after the early return so it runs on every hash change regardless of snapshot state.

    What alternative solutions did you explore? (Optional)

    An alternative would be to fix cleanPreservedNavigatorStates to not delete the search navigator's state on tab switches (by also checking tab-nested route keys). However, this only masks the Onyx staleness — if preserved state were unavailable for any other reason, the bug would resurface. Fixing the source of truth (saveLastSearchParams) is the more robust approach.

    Investigation details

    Data flow of the bug:

    1. User applies merchant:foo filter → URL gets q=type:expense+merchant:foo, saveLastSearchParams saves this to Onyx
    2. User clicks Reset → useUpdateFilterQuery builds the default query, calls Navigation.setParams({q: type:expense+status:all})
    3. URL updates, useSearchPageSetup effect fires for the new hash, but isSnapshotDataLoaded is true (default query was loaded earlier) → saveLastSearchParams is skipped
    4. Onyx REPORT_NAVIGATION_LAST_SEARCH_QUERY still holds the filtered query
    5. User navigates to Workspaces tab → root state changes → cleanPreservedNavigatorStates deletes search navigator's preserved state
    6. User returns to Spend tab → SearchTabButton.navigateToSearch runs → getLastRoute returns undefined → falls back to stale Onyx value → navigates with old filtered query

    Related issues: #89048 appears to describe a related symptom (exposed filter can't be reset after closing Filters RHP).


    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. 6 remaining items

  8. LukasMod commented on May 11, 2026

    @LukasMod
    Contributor

    Fix ready for review, I added chrome/ios video
    #90156

  9. LukasMod commented on May 11, 2026

    @LukasMod
    Contributor

    Main PR was reverted, I recreated it with this fix: #90175

  10. IuliiaHerets commented on May 11, 2026

    @IuliiaHerets

    Chrome / v9.3.69-4
    Still fails

    b1b2390702e861e7f9e993d7457b5b6e.mp4
  11. LukasMod commented on May 11, 2026

    @LukasMod
    Contributor

    @IuliiaHerets Where is the issue in this video? I don't see you applying the filter and resetting it before changing the tab (repro steps 4 and 5).

    1. In the search field type merchant:[anything with no results], apply the filter
    2. Click on the expand button on filter chip, click "Reset"
  12. IuliiaHerets commented on May 11, 2026

    @IuliiaHerets

    Chrome / v9.3.69-10
    Passed

    REC-20260511161845.mp4
  13. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on May 11, 2026
  14. changed the title [-]Spend - Search results appear after resetting filter, navigating to a different tab and back[/-] [+][Due for payment 2026-05-20] Spend - Search results appear after resetting filter, navigating to a different tab and back[/+] on May 13, 2026
  15. melvin-bot commented on May 13, 2026

    @melvin-bot

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

  16. melvin-bot commented on May 13, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.72-1 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-05-20. 🎊

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

    • @dmkt9 requires payment (Needs manual offer from BZ)
  17. melvin-bot commented on May 13, 2026

    @melvin-bot

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

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions