Skip to content

[WIP]fix: reland Search re-fire fix with the deploy blocker regressions closed - #98558

Open
BartekObudzinski wants to merge 3 commits into
Expensify:mainfrom
callstack-internal:fix/search-refire-reland
Open

[WIP]fix: reland Search re-fire fix with the deploy blocker regressions closed#98558
BartekObudzinski wants to merge 3 commits into
Expensify:mainfrom
callstack-internal:fix/search-refire-reland

Conversation

@BartekObudzinski

@BartekObudzinski BartekObudzinski commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Relands #98305, which #98548 reverted over four deploy blockers. The blockers are fixed here and I verified all four flows manually.

98305 stopped a non chat Search from re-firing on every new report action anywhere in the account, which accounted for roughly 26 percent of all Search API calls. It left a non chat search refetching only when the set of transaction IDs changes.

Search rows and the footer total are served from the snapshot_<hash> snapshot. Any flow that changes a field without adding or removing a transaction therefore left the snapshot stale, which is all four blockers:

  • 98494 move to report and 98543 remove from report. The row keeps its pre-move report context, so Submit, Hold, Move to report and the Canadian tax export gate are all wrong.
  • 98502 bulk submit. submitMoneyRequestOnSearch clears the snapshot report only on the submit search key, so on Spend > Expenses the row keeps action: SUBMIT and Submit stays on the menu. The submit itself does reach the server.
  • 98544 edit an expense amount. The footer total is computed by the server, so only a refetch changes it.

Two fixes:

  1. useSearchHighlightAndScroll now also refetches when a transaction the results already display changes value. Onyx keeps one value object per collection member and OnyxCache.merge returns the original object when nothing changed, so an identity check tells an edit from an untouched row exactly. This covers 98494, 98543, 98544 and any other field edit. It cannot restart the loop, because a Search response only writes snapshot keys.
  2. Submitting touches no transaction, so the identity check cannot see it. Both submitMoneyRequestOnSearch call sites in useSearchBulkActions now call refreshSearchAfterReportAction, the same escape hatch approve and pay already use. This covers 98502.

#98498 by @Valforte diagnosed 98494 correctly and I reused its analysis. Its explicit refresh is left out because changeTransactionsReport writes transactions_<id>.reportID optimistically, so the check above already covers those paths.

Worth QA attention: deletion from search results becomes reachable on non chat searches for the first time.

Unit tests: 15/15 in tests/unit/useSearchHighlightAndScrollTest.ts, 1357/1357 across all Search suites. Two tests added, and the new trigger's test was confirmed failing without the fix.

Fixed Issues

$ #98048
PROPOSAL:

Tests

Preconditions

  1. Sign in to two accounts, Account 1 and Account 2, on two devices or browsers.
  2. On Device 1, open DevTools > Network and filter the requests to Search.

The fix

  1. Account 1: open Spend > Expenses.
  2. Account 1: clear the network log in DevTools.
  3. Account 2: open the DM with Account 1 and send a message.
  4. Account 1: verify that no Search request appears in DevTools.

Regression checks

  1. Account 1: create an expense from the right hand panel of the Expenses page, and verify that it appears in the list with its row highlighted.
  2. Account 1: delete an expense from the list, and verify that it disappears from the list.
  3. Account 1: use the search router to run a keyword search and open the Chats results. Have Account 2 send a message to that chat, and verify that the chat results refresh.
  4. Account 1: open Needs approval, approve a report, and verify that the list refreshes.
  5. Account 1: enter selection mode on Ready to pay, pay a report, and verify that the list refreshes.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline.
  2. Open Spend > Expenses, select an expense, edit it or move it to a new report.
  3. Verify no Search request is attempted while offline and the app does not error.
  4. Go back online and verify the list reconciles with the server.

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@BartekObudzinski BartekObudzinski changed the title fix: reland Search re-fire fix with the deploy blocker regressions closed [WIP]fix: reland Search re-fire fix with the deploy blocker regressions closed Aug 13, 2026
@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

Verified ✅
#98544

Screen.Recording.2026-08-13.at.12.24.12.mov

@BartekObudzinski

BartekObudzinski commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Verified ✅
#98543

Screen.Recording.2026-08-13.at.13.19.34.mov

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

Verified ✅
#98502

Screen.Recording.2026-08-13.at.12.53.02.mov

@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

Verified ✅
#98494

Screen.Recording.2026-08-13.at.12.56.13.mov

@BartekObudzinski
BartekObudzinski marked this pull request as ready for review August 13, 2026 11:35
@BartekObudzinski
BartekObudzinski requested review from a team as code owners August 13, 2026 11:35
@melvin-bot
melvin-bot Bot requested a review from QichenZhu August 13, 2026 11:35
@melvin-bot

melvin-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

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

@melvin-bot
melvin-bot Bot requested review from a team, joekaufmanexpensify, mananjadhav and mountiny and removed request for a team August 13, 2026 11:35
@melvin-bot

melvin-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

@mananjadhav @mountiny One of you needs to 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team August 13, 2026 11:35
@BartekObudzinski

Copy link
Copy Markdown
Contributor Author

@codex review

@mountiny
mountiny removed the request for review from mananjadhav August 13, 2026 11:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65a7566c02

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/hooks/useSearchHighlightAndScroll.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant