Refactor getValidOptions#79329
Conversation
|
@bernhardoj 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] |
|
@abzokhattab @danieldoglas 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] |
|
@DylanDylann Please review this PR |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 474b105f67
ℹ️ 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".
| case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_MEMBER_INVITE: | ||
| return getValidOptions(optionsWithContacts, draftComments, nvpDismissedProductTraining, loginList, { | ||
| return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, { | ||
| betas: betas ?? [], | ||
| includeP2P: true, | ||
| includeSelectedOptions: false, |
There was a problem hiding this comment.
Add policies to memo dependencies
The baseOptions useMemo now calls getValidOptions with allPolicies, but allPolicies is not listed in the dependency array, so when policy data loads or changes (e.g., admin role updates, invoice-room eligibility, category settings) the options list will stay stale until another dependency changes. This can hide or show the wrong reports in search until the user types or navigates, which is a regression introduced by adding allPolicies as an input.
Useful? React with 👍 / 👎.
|
Product review not required. Removing myself and unsubscribing |
| const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true}); | ||
| const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: true}); | ||
| const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true}); | ||
| const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); |
There was a problem hiding this comment.
comment to add this PR to k2s list
| const accountIDs = getParticipantsAccountIDsForDisplay(option.item); | ||
|
|
||
| if (excludeNonAdminWorkspaces && !isPolicyAdmin(option.policyID, policies)) { | ||
| if (excludeNonAdminWorkspaces && policy && !isPolicyAdmin(option.policyID, policy)) { |
There was a problem hiding this comment.
Could we move policy check inside isPolicyAdmin?
| return isPolicyAdmin(policyID, policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]); | ||
| }, [policyID, policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]]); |
Reviewer Checklist
Screenshots/VideosScreen.Recording.2026-01-14.at.16.37.51.movAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
Waiting for @dukenv0307 to solve above comments. The rest looks fine |
Co-authored-by: DylanDylann <141406735+DylanDylann@users.noreply.github.com>
|
@dukenv0307 please solve the conflict here so we can merge |
|
@danieldoglas We're good to merge |
|
Kindly bump @danieldoglas |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/danieldoglas in version: 9.3.5-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.3.5-7 🚀
|
Explanation of Change
Fixed Issues
$ #66377
PROPOSAL:
Tests
Test 1:
Test 2:
Test 3:
Offline tests
QA Steps
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
Android: Native
Screen.Recording.2026-01-12.at.16.05.13.mov
Android: mWeb Chrome
Screen.Recording.2026-01-12.at.16.01.07.mov
iOS: Native
Screen.Recording.2026-01-12.at.16.11.05.mov
iOS: mWeb Safari
Screen.Recording.2026-01-12.at.16.00.41.mov
MacOS: Chrome / Safari
Screen.Recording.2026-01-12.at.15.55.24.mov
Screen.Recording.2026-01-12.at.15.54.47.mov