Repository navigation
Skip the optimistic Search row when a new expense doesn't match the active filters - #104832
Conversation
… query filters Co-authored-by: truph01 <truph01@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
|
🤖 Web test steps verification results: With the merchant:I filter on, a new expense with merchant "Gj" did not appear in the filtered Spend results, even after a wait, and it appeared once the filter was cleared. The fix works on web; only the JS console check couldn't run, because the test browser has no console access.
|
|
@MelvinBot Merge main and mark this PR as ready |
Co-authored-by: truph01 <truph01@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🤖 Web test steps verification results: ❌ fail Web verification was blocked: the browser session rendered a blank page with zero nodes, including after five seconds. Human Tests/QA sections remain unchanged.
Merged view run · no recording available |
|
|
|
With a filter the new expense matches (e.g. |
Co-authored-by: truph01 <truph01@users.noreply.github.com>
|
@neil-marcellini 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] |
|
🤖 Web test steps verification results: Web verification stopped before expense setup: the location-access modal could not be dismissed. No browser confirmation was possible.
Fixed and pushed in f7ed13a. You were right: the eligibility check rejected every merchant filter. SearchUpdate.ts:87–111 now evaluates merchant matches, keeping matching rows optimistic while excluding nonmatches. All 2,052 targeted tests passed, including no-server-response coverage. Lint, typecheck, spelling, compiler checks, and Storybook passed. Full Jest testing timed out; formatting verification was unavailable. Details are in AI Tests; human Tests/QA remain unchanged. view run · no recording available |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-11-04.at.17.31.39.movAndroid: mWeb ChromeiOS: HybridAppScreen.Recording.2026-11-04.at.17.29.26.moviOS: mWeb SafariScreen.Recording.2026-11-04.at.17.24.13.movMacOS: Chrome / SafariScreen.Recording.2026-11-04.at.17.21.39.mov |
|
@MelvinBot Update test section in checklist to: |
|
|
neil-marcellini
left a comment
There was a problem hiding this comment.
Good to go. @truph01 I did notice there's a weird flash in your testing video when the new expense is added. Can we please figure out what's causing that and get rid of it in a follow up? Is it new in this PR or did it already exist on main?
|
🚧 neil-marcellini has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
Looks good from Product: #104832 (comment) |
|
🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.5.33-0 🚀
|











Explanation of Change
When you create an expense from Spend,
useOptimisticSearchTrackingadds the new transaction to the list before the server responds. It did this without checking the active query. With a restrictive filter such asmerchant:I, the server correctly leaves the expense out, so tracking never resolved and the row stayed on screen.This PR reuses
shouldOptimisticallyUpdateSearch, the check that already gates the optimistic Onyx snapshot update, in the tracking hook:searchDataWithOptimisticTransactionstays a pure calculation. It skips the transaction when it doesn't match the query.clearOptimisticTracking()in that case. This drops the pending-expense placeholder and stops tracking, without callingsetStateduring render.REPORTcollection), so the policy and status checks work the same as inSearchUpdate.ts.currentUserAccountIDcomes fromuseSearchSnapshot, which already has it.Queries with no restrictive filters behave as before: the new row still appears right away.
Updated 2026-11-04: Corrected based on feedback from
truph01. The shared eligibility check previously rejected every merchant-filtered search, including matching expenses. It now evaluates the effective merchant using the parsed contains, equality, and inequality operators, preserves clause/list semantics, and retains existing restrictions for other filters. Both optimistic snapshot updates and tracking use this check, so matching merchant expenses no longer depend on a server response.AI tests run locally before the main merge:
npm test -- tests/unit/Search/ tests/actions/IOU/SearchUpdateTest.ts: 61 suites, 1834 tests passed. The new test fails without the fix.npm run typecheck,npm run linton changed files,npm run spell-changed,npm run fmt(oxfmt), andreact-compiler-compliance-check checkon the changed hooks: all passed.npm testsuite and the Storybook smoke test (no UI or story changes). A web UI check was attempted, but the test browser session rendered a blank page, so it couldn't run.AI Tests
After correcting matching merchant filters on 2026-11-04:
prettierscript does not exist; direct formatter invocation was denied by this environment. No formatting pass is claimed.After merging main on 2026-11-04:
get/multiGetAPIs outside this PR's changes.get/multiGet,modern-screenshot, andoxlint; no errors reported in the three PR-specific files.origin/; the explicit hook check passed.prettiernpm script no longer exists on main.Blocked web verification screenshot
Fixed Issues
$ #104147
PROPOSAL: #104147 (comment)
Tests
Offline tests
Covered by automated tests.
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.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