Fix search inline filter bar changes being wiped by useSearchFilterSync race condition#84050
Conversation
…ition The filter sync hook was moved to useSearchFiltersBar in Expensify#83602, which introduced a race condition where inline filter changes get wiped by the sync hook before Navigation.setParams fires (deferred by Modal.close()). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@hungvu193 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c286aafde
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const isMobileSelectionModeEnabled = useMobileSelectionMode(clearSelectedTransactions); | ||
|
|
||
| const queryJSON = useMemo(() => buildSearchQueryJSON(route.params.q, route.params.rawQuery), [route.params.q, route.params.rawQuery]); | ||
| const filterFormValues = useFilterFormValues(queryJSON); |
There was a problem hiding this comment.
Keep filter-form subscriptions out of SearchPage
useFilterFormValues() subscribes to broad Onyx collections (CARD_LIST, POLICY, REPORT, etc. in src/hooks/useFilterFormValues.tsx), and this new call in SearchPage makes the entire page re-render whenever those datasets change, even if the search query is unchanged. Because useSearchFiltersBar still calls useFilterFormValues(queryJSON), this commit introduces a second subscription path and expands the rerender scope from the filter bar to the full search screen, which can noticeably degrade performance during frequent Onyx/Pusher updates.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This used to be the case before https://github.com/Expensify/App/pull/83602/changes
|
@luacmartins I can review this in case we are looking for a C+ as other PR(which I am reviewing) testing needs this to be fixed. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
Bug(not sure): Updated filter value in advance filter visible in the search filter bar without the final button(View Results) click To highlight, it is not from this PR, reproducible on prod too. Screen.Recording.2026-03-04.at.00.28.23.mov |
Pujan92
left a comment
There was a problem hiding this comment.
LGTM!
Screen.Recording.2026-03-04.at.00.34.26.mov
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
…ters-sync Fix search inline filter bar changes being wiped by useSearchFilterSync race condition (cherry picked from commit 4283bed) (cherry-picked to staging by blimpich)
|
🚧 @luacmartins has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Cherry-picked to staging by https://github.com/blimpich in version: 9.3.28-7 🚀
|
|
🚀 Cherry-picked to staging by https://github.com/blimpich in version: 9.3.30-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.30-3 🚀
|
|
🚀 Cherry-picked to staging by https://github.com/blimpich in version: 9.3.31-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.31-12 🚀
|
Explanation of Change
useSearchFilterSyncwas previously called insideuseSearchFiltersBar, which is rendered as part of the inline filter bar. This created a race condition: when a user selects a value in an inline filter (e.g. the "From" filter), the filter picker closes viaModal.close(), which defersNavigation.setParamsto after the modal close animation. During that window,useSearchFilterSyncwould run and overwrite the pending param change with stale values, effectively wiping the user's filter selection.The fix moves
useSearchFilterSync(and its dependencyuseFilterFormValues) back up toSearchPage.tsx, which is the correct owner of this sync logic. This matches the original placement before PR #83602 and ensures the sync hook runs at the page level rather than inside a child component that may re-render at the wrong time.Fixed Issues
$ #83988
$ #83951
PROPOSAL:
Tests
Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari