Migrate useSearchSelector.base.ts from useOptionsList to usePersonalDetailOptions (part 2)#91986
Conversation
…etailOptions (part 2)
|
@hoangzinh 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe904c4ab6
ℹ️ 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".
| setSelectedAccountIDs(new Set([option.accountID.toString()])); | ||
| if (!existingAccountIDs.has(option.accountID.toString())) { | ||
| setExtraOptions([{...option, isSelected: true}]); |
There was a problem hiding this comment.
Clear stale extra option when replacing a single selection
When shouldUpdateSelectedOptionsOnSingleSelect is used and the current selection is an optimistic invite stored in extraOptions, selecting an existing contact reaches this branch and updates selectedAccountIDs but leaves the old extraOptions entry marked selected because setExtraOptions only runs for non-existing new options. The hook then returns both the existing contact and the stale invite in selectedOptions/selected sections, so the domain add-admin single-select UI can show two selected users until the stale invite is toggled off. Clear extraOptions whenever a different single selection replaces the previous one.
Useful? React with 👍 / 👎.
| selected: true, | ||
| }; | ||
| return getParticipantsOption(participant, personalDetails) as OptionData; | ||
| const initialSelected = useMemo(() => new Set(Object.values(invitedEmailsToAccountIDsDraft ?? {}).map(String)), [invitedEmailsToAccountIDsDraft]); |
There was a problem hiding this comment.
Preserve drafted invitees that are not personal details
For a workspace invite draft containing a newly typed email/phone, the draft stores login -> optimisticAccountID, but this new initialSelected keeps only the account IDs. usePersonalDetailSearchSelector can only hydrate selected IDs that exist in the personal-details options and it does not recreate extraOptions from this set, so returning to this page from the invite-message flow drops those drafted new invitees from selectedOptions; pressing Invite again then rewrites the draft without them. Keep the login data (or seed extraOptions) for drafted invitees that are not in personal details.
Useful? React with 👍 / 👎.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Explanation of Change
Fixed Issues
$ #82191
Tests
Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Screen.Recording.2026-05-28.at.9.03.25.PM.mov