Skip to content

Fix #88730: show invite-as-user row for unknown emails in SearchRouter#89405

Open
15antonian wants to merge 8 commits into
Expensify:mainfrom
15antonian:fix/88730-search-invite-user-label
Open

Fix #88730: show invite-as-user row for unknown emails in SearchRouter#89405
15antonian wants to merge 8 commits into
Expensify:mainfrom
15antonian:fix/88730-search-invite-user-label

Conversation

@15antonian
Copy link
Copy Markdown

@15antonian 15antonian commented May 1, 2026

Explanation of Change

Two compounding bugs prevented the "Invite" affordance from appearing when an unknown email is typed in the SearchRouter:

Bug 1 — canCreateOptimisticPersonalDetailOption used a zero-results gate (recentReportOptions.length + personalDetailsOptions.length > 0 → return false). This suppressed userToInvite entirely whenever any partial-match contact existed in the results, even when none of those matches was the typed email address. Replaced with an exact-login-match check: userToInvite is now suppressed only when a contact with that exact login already appears in the results.

Bug 2 — Missing "Invite" label. When searchOptions.userToInvite was non-null, it was pushed into the flat reportOptions array with both text and alternateText set to the raw email (the default from getUserToInviteOption). The row was visually indistinguishable from a regular contact. Fixed by spreading alternateText: translate('common.invite') onto the invite item when appending it, which renders "Invite" in the secondary text position — matching every other surface in the app that surfaces userToInvite (NewChatPage, RoomInvitePage, etc). No new translation strings needed; common.invite already exists.

Fixed Issues

$ #88730
PROPOSAL: #88730 (comment)

Tests

  1. Sign in to the app
  2. Click the Search button (magnifying glass) to open the SearchRouter
  3. Type an email address that has no Expensify account (e.g. nobody-test-88730@unknown-domain-xyz.com)
  4. Verify a row appears with that email as primary text and "Invite" as secondary text
  5. Click the row — verify it opens a new DM/invite flow for that address
  6. Repeat steps 2–4 while also having contacts whose names partially match the query (e.g. a contact named "Nobody Test") — verify the invite row still appears alongside the partial-match results
  • Verify that no errors appear in the JS console

Offline tests

The userToInvite row is constructed from the locally typed query with an optimistic accountID — no network call is needed to render it. Go offline after loading the app, open the SearchRouter, type an unknown email, and verify the invite row still appears.

QA Steps

  1. Open the SearchRouter (search icon, top-right)
  2. Type a valid email address that is not registered with Expensify (e.g. qa-test-88730@expensify-qa-unknown.com)
  3. Expected: A row appears showing the email with "Invite" as the subtitle
  4. Previously broken: No invite row appeared (or row had email repeated as both title and subtitle with no label)
  5. Tap/click the row and verify it opens a new chat / invite flow
  • 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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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.mp4
Android: mWeb Chrome

Not tested — see MacOS: Chrome / Safari and iOS: mWeb Safari for mWeb coverage.

iOS: Native
ios.mp4
iOS: mWeb Safari

Not tested — see MacOS: Chrome / Safari and iOS: mWeb Safari for mWeb coverage.

MacOS: Chrome / Safari
web.mp4
mweb.mp4

15antonian and others added 2 commits May 1, 2026 14:43
…earchRouter

canCreateOptimisticPersonalDetailOption used a zero-results gate that
suppressed userToInvite whenever any partial-match contact existed.
Replace with an exact-login-match check so the invite row appears even
when other contacts are present. Label it with translate('common.invite')
in SearchAutocompleteList so it renders as "Invite" rather than the raw
email, matching every other userToInvite surface in the app.
…nsify#88730

Verify that the invite row appears when partial-match contacts exist but
none has an exact login match, and that it is suppressed when an exact
match is found.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@15antonian 15antonian requested review from a team as code owners May 1, 2026 18:53
@melvin-bot melvin-bot Bot requested review from JmillsExpensify and ZhenjaHorbach and removed request for a team May 1, 2026 18:53
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented May 1, 2026

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

@15antonian
Copy link
Copy Markdown
Author

Web (MacOS Chrome) — after fix:

Typing an unknown email now shows the "Invite" row:

web-after-fix

mWeb (375px viewport) — after fix:

mweb-after-fix

Screenshots taken at https://dev.new.expensify.com:8082/ on branch fix/88730-search-invite-user-label.

Both show: typing nobody88730@unknown-domain-xyzabc.com → row appears with email as primary text and "Invite" as secondary text.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

@15antonian
Don't create your PR until you are assigned

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

But sorry
I see that you are assigned 😅

Copy link
Copy Markdown

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

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: 57361654b6

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

Comment thread src/libs/OptionsListUtils/index.ts Outdated
Comment on lines +1926 to +1927
const hasExactLoginMatch =
recentReportOptions.some((o) => o.login?.toLowerCase() === normalizedSearchValue) || personalDetailsOptions.some((o) => o.login?.toLowerCase() === normalizedSearchValue);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Compare raw phone logins before adding invite row

The new exact-match gate only compares option logins against addSMSDomainIfPhoneNumber(searchValue), which misses existing contacts whose login is stored as raw E.164 (e.g. +15005550006 without @expensify.sms). In that case, typing that exact phone number still passes canCreateOptimisticPersonalDetailOption, so userToInvite is created even though an exact contact already exists, yielding a duplicate/inaccurate “Invite” result. This regression is reachable in flows where phone logins are kept without the SMS suffix.

Useful? React with 👍 / 👎.

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.

Makes sense

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.

@15antonian
Check this comment please

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch, addressed. Updated canCreateOptimisticPersonalDetailOption to also match logins stored as raw E.164 (no @expensify.sms suffix), and added two regression tests covering both storage formats. Existing tests still pass.

@15antonian
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

And please
Record videos for all platforms

@15antonian
Copy link
Copy Markdown
Author

Will send the others shortly.

@15antonian
Copy link
Copy Markdown
Author

Videos added for all platforms — Android Native, iOS Native, iOS mWeb Safari, and MacOS Chrome. Android mWeb Chrome shares the same code path as iOS mWeb Safari (covered by that recording).

@15antonian
Copy link
Copy Markdown
Author

Hi @ZhenjaHorbach, friendly bump for re-review when you have a chance. Happy to record any additional platforms if helpful, just let me know.

@15antonian
Copy link
Copy Markdown
Author

@CLAassistant ok recheck

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

ZhenjaHorbach commented May 11, 2026

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 proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 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 a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

Android: HybridApp
2026-05-17.16.15.10.mov
Android: mWeb Chrome
2026-05-17.16.24.18.mov
iOS: HybridApp
2026-05-17.16.15.10.mov
iOS: mWeb Safari
2026-05-17.16.24.18.mov
MacOS: Chrome / Safari
2026-05-17.16.07.31.mov

@15antonian
Copy link
Copy Markdown
Author

Hi @ZhenjaHorbach, friendly bump to close this one out. I've added the additional check and updated the unit test. Thanks!

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

ZhenjaHorbach commented May 12, 2026

Will check today
And the PR Author Checklist + CLA Assistant are not completed

@15antonian
Copy link
Copy Markdown
Author

@CLAassistant ok recheck

@15antonian
Copy link
Copy Markdown
Author

Hi @ZhenjaHorbach — I signed the CLA on May 1st by posting the required comment, but the CLA bot failed with: Error: Could not update the JSON file: Repository rule violations found — Commits must have verified signatures. My entry was never written to cla.json. Could you help get this resolved or manually trigger the bot? Thanks!

@15antonian
Copy link
Copy Markdown
Author

recheck

exfy-clabot Bot added a commit to Expensify/CLA that referenced this pull request May 13, 2026
@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

I'm working on it
Will complete today or tomorrow morning

@15antonian
Copy link
Copy Markdown
Author

Looks like the CLA workflow passed.
@ZhenjaHorbach

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

Sorry for delay
Had more priority issues
I will complete reviewing today or on the weekend

@melvin-bot melvin-bot Bot requested a review from AndrewGable May 17, 2026 14:25
@AndrewGable
Copy link
Copy Markdown
Contributor

Can you look into the failing tests?

@ZhenjaHorbach
Copy link
Copy Markdown
Contributor

ZhenjaHorbach commented May 18, 2026

I suppose it will be enough to update the branch to the latest version of main to fix perf tests

@15antonian
Copy link
Copy Markdown
Author

Yes that was it. Thank you. @ZhenjaHorbach

Failiing tests are now passing @AndrewGable

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/components/Search/SearchAutocompleteList.tsx 92.52% <100.00%> (+3.51%) ⬆️
src/libs/OptionsListUtils/index.ts 84.83% <ø> (+0.09%) ⬆️
... and 341 files with indirect coverage changes

AndrewGable
AndrewGable previously approved these changes May 19, 2026
…n SearchAutocompleteList

Covers the branch added in Expensify#88730 where userToInvite is spread with
alternateText: translate('common.invite') before being pushed to
recentReportsOptions. Closes the Codecov coverage gap on line 377
of SearchAutocompleteList.tsx.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@15antonian
Copy link
Copy Markdown
Author

Tests are passing locally and I've added a UI test to cover the new code path in SearchAutocompleteList. Ready for re-review.

@AndrewGable
Copy link
Copy Markdown
Contributor

Tests are failing (eslint)

@AndrewGable
Copy link
Copy Markdown
Contributor

I think on your next prs you should have the tests run automatically instead of needing to be approved every time so hopefully will prevent the failing test loop.

@AndrewGable
Copy link
Copy Markdown
Contributor

Last commit was not signed, can you resign it? https://superuser.com/a/428474

The ui/ test suite is what Codecov instruments. Adds a case that passes
userToInvite via the mocked getSearchOptions and asserts the "Invite"
alternateText is rendered, covering line 377 of SearchAutocompleteList.tsx.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@15antonian 15antonian force-pushed the fix/88730-search-invite-user-label branch from 2bc1455 to f0db258 Compare May 20, 2026 19:55
const styles = useThemeStyles();

if (isSearchQueryListItem(props)) {
return <SearchQueryListItem {...props} />;
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.

Why do we need these changes?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The react/jsx-props-no-spreading ESLint rule forbids JSX prop spreading the {...props} here caused a CI failure.

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.

Don't see any issues with the pipeline in this place in your previous commits
Do you have this issue locally?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ran it locally. npx eslint src/components/Search/SearchAutocompleteList.tsx throws error Prop spreading is forbidden react/jsx-props-no-spreading at line 111. CI also failed on that check in the run right before this fix.

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.

Are you sure?

Снимок экрана — 2026-05-20 в 22 42 12

And update node_modules and try recheck, please

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You're right, the original had an eslint-disable-next-line comment suppressing it. I removed that and replaced the spread with explicit props instead, which is the proper fix rather than suppressing the rule. Happy to revert to the disable comment if preferred.

Copy link
Copy Markdown
Contributor

@ZhenjaHorbach ZhenjaHorbach May 20, 2026

Choose a reason for hiding this comment

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

Where? 😅
Image

And I just want to avoid changes that are not related to the fix in our PR
So let's revert these changes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Reverted. My bad that eslint-disable comment was introduced by me in this PR, not from main. Reverted to the plain spread

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.

3 participants