Skip to content

[No QA] Add baseline search parity test for SearchRouter (Part 1/3) - #104510

Merged
mountiny merged 18 commits into
Expensify:mainfrom
software-mansion-labs:jmgraa/search-router-golden-master
Oct 30, 2026
Merged

mountiny merged 18 commits into
Expensify:mainfrom
software-mansion-labs:jmgraa/search-router-golden-master

Conversation

@jmgraa

@jmgraa jmgraa commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Update: Parts 2/3 and 3/3 were combined into a single follow-up #105898, so this series ends at two parts.

This is Part 1 of a 3-part stacked PR series introducing a golden master regression harness for SearchRouter option search.

The harness records, on main and before the upcoming in-memory SearchOptionsIndex, what the existing OptionsListUtils pipeline (createFilteredOptionList through getSearchOptions) returns for a deterministic account, so later refactors can prove they change nothing.

Stack:
  ➔ [PR 1/3] Add baseline search parity test for SearchRouter
    [PR 2/3] Add autocomplete filters, tie-breaking and permutation invariants
    [PR 3/3] Check search results after Onyx updates against a cold build
  • tests/utils/searchParity/generateSearchFixture.ts: a deterministic account with fixed IDs, unique timestamps and unique contact names. It covers 1:1 DMs, a group chat, a self-DM, own and others' workspace chats, an invoice room, #admins/#announce/custom rooms (one with an error, one whose workspace is gone), threads (with replies, hidden, empty, drafted, pinned), a task, expense reports, an archived DM, a DM with an unknown participant, and 40 filler contacts.
    • Stored names: Vít Novák, José Ñúñez, İsmail Yılmaz, Groß Straße, Łukasz Wójcik, Οδυσσεύς, Zoë 👩‍💻 (ZWJ), Ana​Maria (U+200B), Bob Builder (NBSP), NFD-decomposed René Dupont, first.last+tag@x.com, an SMS login.
    • Queries include prefixes, infixes, multi-word, punctuation, phone digits, regex metacharacters, emails to invite, and query-side normalization (JOSÉ, İSMAIL, Vít, René, Groß, an existing contact's phone and the own login, which must not invite).
  • tests/unit/OptionsListUtilsSearchParityTest.ts: runs the production configs and records the results.
    • Option lists: searching (content only), SearchRouter idle at a small cap and at the production cap.
    • Call sites: searchRouterLocal (the SearchAutocompleteList local pass) and searchRouterDisplayed (its ranking via combineOrderingOfReportsAndPersonalDetails, the userToInvite append and the 20-row cap, recorded as the displayed rows only) for every query.
    • Blank and whitespace-only queries search the production-cap idle list, since SearchAutocompleteList's loadAll expands lists under 20 rows. The small-cap list is only recorded, never searched.
    • Passes: the server-ID pass in Auth order, including the self-DM, reports the canonical filter rejects and an ID with no local report, all of which it drops; and the SearchRouter opened over a focused empty thread or empty submitted report, which only appear while focused.

Serialization

Each option is one diff-friendly line:

<keyForList> <text> [flags] [alt: ...] [sub: ...] [accID: ...] [invitedLogin]
  • [flags]: [selected], [disabled], [bold], [gbr], [rbr], [archived].
  • [alt: ...]: alternateText (chat previews in search results).
  • [sub: ...]: subtitle, only for rooms and workspace chats, because that is what search matches for them.
  • [accID: ...]: the option's accountID, printed whenever it is non-zero (1:1 rows and contacts; groups and rooms carry none).
  • [invitedLogin]: only on userToInvite, when its login differs from its text.

Fields the SearchRouter never reads (participantsList, icons, policyID, ownerAccountID, item) are deliberately not serialized.

Notes

  • getReportByID is kept stable per reports collection with a WeakMap, as useCallback(..., [allReports]) does in useFilteredOptions, so the preview cache is not invalidated between queries.
  • hasMore is recorded from getSearchOptions; no SearchRouter consumer reads it (the router's hasMore comes from useFilteredOptions).
  • Snapshot policy: re-record (npm test -- tests/unit/OptionsListUtilsSearchParityTest.ts -u) only against the pre-migration pipeline on main, so the migration never becomes its own oracle.

Fixed Issues

$ #103148
PROPOSAL:

Tests

Run npm test -- tests/unit/OptionsListUtilsSearchParityTest.ts.

  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

N/A

  • 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 verified any copy / text that was added to the app 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 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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.

@jmgraa

jmgraa commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T15:28:46.340806Z ce46338 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jmgraa

jmgraa commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@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: c87406c694

ℹ️ 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".

@JakubKorytko JakubKorytko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Really like the golden master idea, it's a good safety net for the migration. The main thing is where the test drifts from what the app passes in (activePolicyID, the system account IDs, rules/policy tags), since the snapshot can't catch a change in behavior it never recorded. The rest is small. I didn't mark every missing blank line before a comment, could you go through the files for the others?

@JakubKorytko

Copy link
Copy Markdown
Member

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The harness mirrors the production call sites closely. I found three gaps not raised in the earlier review comments. In each one, a snapshot entry looks like it pins a rule but does not.

1. "Hidden thread" does not pin the hidden-thread rule.
generateSearchFixture.ts:534-537 creates the thread with no replies. The empty-thread rule in ReportUtils.ts:11249-11251 already drops it, whatever its notification preference. The proof is that "Empty thread" (2023) has the same shape, is not hidden, and is also missing from the thread results. If someone removed the excludeHidden thread check in OptionsListUtils/index.ts:2451-2454, the snapshot would not change.
Fix: give it a reply (addReply(addThread(2022, ...), ...)) so only the hidden rule can drop it. The comment above it also mentions a task share call site, which is not part of this PR.

2. The blank-query call-site entries record a state the SearchRouter never shows.
getOptionListKind sends '' to the cap-10 searchRouterIdle list, so both call sites record only 8 rows for "". Production starts at cap 100. If fewer than 20 rows survive, the loadAll effect in SearchAutocompleteList.tsx:834-840 expands the list, so an 8-row result can't happen. passes.searchRouterBlankAtProductionCap already records the real state.
Fix: use the production-cap list for blank queries, or drop '' from the call-site matrix.

3. The focused "Empty thread" blank entry duplicates the unfocused one.
The thread is report 47 in the production-cap order, which is past the 20-row display cap. Its blank result is therefore the same 20 rows as searchRouterBlankAtProductionCap (snapshot lines 57-76 vs 102-121). Only the empty query shows the focused thread.
Fix: make the thread recent enough to land in the top 20, or record only the empty query for it.

I did not run the suite. These findings come from reading the code and the committed snapshot at 5e0a29cc.


view run

@jmgraa

jmgraa commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

All three addressed:

  1. Hidden thread now has a reply. The snapshot didn't change, but disabling excludeHidden fails 3/4 tests, so the rule is pinned.
  2. Blank queries now search the production-cap list. The duplicate blank pass is removed.
  3. Empty thread now records only the empty query.

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 17 files with indirect coverage changes

@jmgraa

jmgraa commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 359f790f03

ℹ️ 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".

@jmgraa
jmgraa force-pushed the jmgraa/search-router-golden-master branch from b7a1c18 to fe6546f Compare October 27, 2026 13:03
@jmgraa

jmgraa commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@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: fe6546f568

ℹ️ 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".

@jmgraa
jmgraa force-pushed the jmgraa/search-router-golden-master branch from fe6546f to ce46338 Compare October 27, 2026 15:02
@jmgraa
jmgraa marked this pull request as ready for review October 27, 2026 15:04
@jmgraa
jmgraa requested a review from a team as a code owner October 27, 2026 15:04
@melvin-bot
melvin-bot Bot requested review from eVoloshchak and removed request for a team October 27, 2026 15:05
@melvin-bot

melvin-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown

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

@eVoloshchak

eVoloshchak commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app 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 verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

MacOS: Chrome / Safari Screenshot 2026-10-28 at 17 59 45

@eVoloshchak eVoloshchak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@melvin-bot
melvin-bot Bot requested a review from mountiny October 28, 2026 17:01
@grgia
grgia self-requested a review October 29, 2026 13:57

@grgia grgia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ran the parity test on this branch merged into current main and it passes. One non-blocking thought on keeping the harness tied to the screen's config, inline.

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks

@mountiny
mountiny merged commit 1e85328 into Expensify:main Oct 30, 2026
37 of 38 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.27-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify

OSBotify commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/blimpich in version: 9.5.27-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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.

8 participants