Trim search term before deriving the phone/email search value in useSearchSelector - #100031
Draft
MelvinBot wants to merge 1 commit into
Draft
Trim search term before deriving the phone/email search value in useSearchSelector#100031MelvinBot wants to merge 1 commit into
MelvinBot wants to merge 1 commit into
Conversation
…earchSelector Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
7 tasks
Contributor
Author
|
🤖 Android test steps verification results: ✅ pass PR #100031's search-term trim fix verified end-to-end on Android: leading/trailing-space email and phone searches still surface the invite row in both Start Chat and the Submit Expense participant picker, and selecting the padded row always yields a trimmed login.
No console errors were observed. |
Contributor
Author
|
🤖 Web test steps verification results: ✅ pass Verified on dev NewDot web: leading/trailing spaces no longer hide the email/phone invite row in Start chat and in the Submit-expense participant picker, and selecting a space-padded invite correctly opens/confirms with the trimmed value. Confirms the
No console errors were observed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



















Explanation of Change
In Start chat, typing the email of a user who has no Expensify account made the "invite" row disappear as soon as the input had a leading or trailing space.
useSearchSelectorderived the email/phone search value from the raw debounced input, so the space survived:That untrimmed value flowed into
getValidOptions→filterUserToInvite→getUserToInviteOption, whereStr.isValidEmailuses an anchored^…$regex. A boundary space fails the match, so withisValidEmail === false,isValidPhoneNumber === falseandshouldAcceptName === falsethe guard returnednulland no invite option was created. Existing accounts still matched because report/personal-detail filtering tokenizes on whitespace and drops empty tokens — which is exactly the asymmetry the reporter saw.The fix swaps the order of those two lines so the already-computed trimmed value feeds
getSearchValueForPhoneOrEmail. This matches what the olderfilterOptionspath has always done (it trims before deriving the invite search value), so the two code paths now agree.Why fix it here rather than inside
getSearchValueForPhoneOrEmail: that helper has 11 other call sites (ApproverSelectionList,WorkspaceMembersSelectionList,ReportSubmitToContent,DomainAddPrimaryContactPage,ShareBankAccount,UnshareBankAccount, bothAssigneeSteps,ChangeReceiptBillingAccountPage,DynamicInviteReceiptPartnerPolicyPage,WorkspaceWorkflowsPayerPage) that don't have this bug and mostly feedtokenizedSearch. Fixing it in the hook keeps the change contained while still covering both affected screens, sinceSEARCH_CONTEXT_GENERALwithincludeUserToInviteis used by Start chat and byParticipantSearchResults(the participant picker for split/submit expense).Two side effects worth calling out, both improvements:
SEARCH_CONTEXT_SEARCHpath (getSearchOptions) now also receives a trimmed query.' +1 (234) 567-8901 'failed to parse and was passed through verbatim.AI tests run locally
npm test -- tests/unit/useSearchSelectorTest.tsx tests/unit/usePersonalDetailSearchSelectorTest.tsx tests/unit/OptionsListUtilsTest.tsxnpm test -- tests/ui/NewChatPageTest.tsxnpm run lint-changednpm run typechecknpm run fmt(oxfmt)npm run react-compiler-compliance-check check src/hooks/useSearchSelector/base.tsnpm run spell-changed4 new unit tests were added in
tests/unit/useSearchSelectorTest.tsx. All 4 were confirmed to fail against the unfixed code and pass with the fix.Fixed Issues
$ #99419
PROPOSAL: #99419 (comment)
Tests
// TODO: The human co-author must fill out the tests they ran before marking this PR as "ready for review".
Suggested steps (not yet run by a human — Melvin's browser verification was blocked by a harness failure):
notanaccount99419@example.com). Verify the invite row appears.+1 (234) 567-8901) still surfaces the invite row.Offline tests
Same as tests. The change is purely client-side string handling in the search selector and does not add or alter any API call, so behavior is unchanged offline.
QA Steps
// TODO: The human co-author must fill out the QA steps before marking this PR as "ready for review".
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Melvin's blocked browser session (not a test result)
Melvin could not verify this in the browser — the CI-provided session was stuck on a blank page after sign-in. Kept here as evidence of the harness failure, not as test coverage.
Last known good state from session prestart: post-sign-in Welcome/Join screen
Blocked session state: blank white page with 0 accessible nodes
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari