-
Notifications
You must be signed in to change notification settings - Fork 3.5k
refactor getMemberInviteOptions #80201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@DylanDylann 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] |
src/pages/RoomInvitePage.tsx
Outdated
| const [userSearchPhrase] = useOnyx(ONYXKEYS.ROOM_MEMBERS_USER_SEARCH_PHRASE, {canBeMissing: true}); | ||
| const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false}); | ||
| const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true}); | ||
| const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ PERF-11 (docs)
Fetching the entire policy collection without a selector causes unnecessary re-renders. Since getMemberInviteOptions passes reports: [] to getValidOptions, the policies are never actually used in this code path, but the component will still re-render whenever any policy in the collection changes.
Suggested fix: If policies are not needed for this use case, pass undefined instead. If they might be needed in the future, add a selector to fetch only the required fields:
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {
canBeMissing: true,
selector: (policies) => {
// Return only the fields actually needed by getMemberInviteOptions
// Or return undefined if not needed at all
if (!policies) return undefined;
// Example: return specific policy fields if needed
},
});Alternatively, if the policies are truly not used, consider passing undefined to avoid the subscription entirely.\n\n---\n\nPlease rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
…stead of allPolicies
9af3cf6 to
b1263a0
Compare
|
@DylanDylann in getMemberInviteOptions we passed includeRecentReports: false, so |
heyjennahay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Product review not required
tests/unit/OptionsListUtilsTest.tsx
Outdated
| it('should return personal details with expected structure', () => { | ||
| // Given a set of personalDetails | ||
| // When we call getMemberInviteOptions | ||
| const results = getMemberInviteOptions(OPTIONS.personalDetails, nvpDismissedProductTraining, loginList, [CONST.BETAS.ALL]); | ||
|
|
||
| // Then personal details should be returned | ||
| expect(results.personalDetails.length).toBeGreaterThan(0); | ||
|
|
||
| // Then the results should contain expected structure | ||
| expect(results.recentReports).toEqual([]); | ||
| expect(results.currentUserOption).toBeUndefined(); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please integrate this case into the existing one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
| it('should exclude logins when excludeLogins is provided', () => { | ||
| // Given a set of personalDetails and excludeLogins | ||
| const excludeLogins = {'reedrichards@expensify.com': true}; | ||
|
|
||
| // When we call getMemberInviteOptions with excludeLogins | ||
| const results = getMemberInviteOptions(OPTIONS.personalDetails, nvpDismissedProductTraining, loginList, [], excludeLogins); | ||
|
|
||
| // Then the excluded login should not be in the results | ||
| const excludedUser = results.personalDetails.find((detail) => detail.login === 'reedrichards@expensify.com'); | ||
| expect(excludedUser).toBeUndefined(); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please integrate this case into the existing one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we should keep it separately because in this case, we have excludedUser
Reviewer Checklist
Screenshots/VideosScreen.Recording.2026-01-27.at.15.25.05.mov |
|
@dukenv0307 Minor comments on new test case. The rest looks good |
|
@DylanDylann Done |
|
✋ 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.11-16 🚀
|
Explanation of Change
Fixed Issues
$ #66377
PROPOSAL:
Tests
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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-01-22.at.16.34.11.mov