Skip to content

Commit

Permalink
useMemo excludedUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
eh2077 committed Jul 27, 2023
1 parent 0394de0 commit 16c34bb
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,10 @@ function WorkspaceInvitePage(props) {

useOnNetworkReconnect(openWorkspaceInvitePage);

const excludedUsers = useMemo(() => PolicyUtils.getIneligibleInvitees(props.policyMembers, props.personalDetails), [props.policyMembers, props.personalDetails]);

useEffect(() => {
const inviteOptions = OptionsListUtils.getMemberInviteOptions(
props.personalDetails,
props.betas,
searchTerm,
PolicyUtils.getIneligibleInvitees(props.policyMembers, props.personalDetails),
);
const inviteOptions = OptionsListUtils.getMemberInviteOptions(props.personalDetails, props.betas, searchTerm, excludedUsers);

// Update selectedOptions with the latest personalDetails and policyMembers information
const detailsMap = {};
Expand Down Expand Up @@ -188,7 +185,6 @@ function WorkspaceInvitePage(props) {
);

const headerMessage = useMemo(() => {
const excludedUsers = PolicyUtils.getIneligibleInvitees(props.policyMembers, props.personalDetails);
const searchValue = searchTerm.trim();
if (!userToInvite && CONST.EXPENSIFY_EMAILS.includes(searchValue)) {
return translate('messages.errorMessageInvalidEmail');
Expand All @@ -197,7 +193,7 @@ function WorkspaceInvitePage(props) {
return translate('messages.userIsAlreadyMemberOfWorkspace', {login: searchValue, workspace: policyName});
}
return OptionsListUtils.getHeaderMessage(personalDetails.length !== 0, Boolean(userToInvite), searchValue);
}, [props.policyMembers, props.personalDetails, translate, searchTerm, policyName, userToInvite, personalDetails]);
}, [excludedUsers, translate, searchTerm, policyName, userToInvite, personalDetails]);

return (
<ScreenWrapper shouldEnableMaxHeight>
Expand Down

0 comments on commit 16c34bb

Please sign in to comment.