From 05d8890ba1fd2889a147de26c0fcbc3de72b36ca Mon Sep 17 00:00:00 2001 From: someone-here Date: Thu, 12 Oct 2023 15:22:07 +0530 Subject: [PATCH 1/6] Set accountID to number --- src/pages/workspace/WorkspaceMembersPage.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index b0aaa001817f..21eb5e43825b 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -265,7 +265,8 @@ function WorkspaceMembersPage(props) { const getMemberOptions = () => { let result = []; - _.each(props.policyMembers, (policyMember, accountID) => { + _.each(props.policyMembers, (policyMember, accountIDKey) => { + const accountID = Number(accountIDKey); if (isDeletedPolicyMember(policyMember)) { return; } @@ -314,8 +315,8 @@ function WorkspaceMembersPage(props) { result.push({ keyForList: accountID, - accountID: Number(accountID), - isSelected: _.contains(selectedEmployees, Number(accountID)), + accountID: accountID, + isSelected: _.contains(selectedEmployees, accountID), isDisabled: accountID === props.session.accountID || details.login === props.policy.owner || From eb6e9c2bf6b2cbfcd683644e9bbd3088dbe50816 Mon Sep 17 00:00:00 2001 From: someone-here Date: Thu, 12 Oct 2023 15:28:22 +0530 Subject: [PATCH 2/6] Set list key to string --- src/pages/workspace/WorkspaceMembersPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 21eb5e43825b..52793599dd35 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -314,7 +314,7 @@ function WorkspaceMembersPage(props) { const isAdmin = props.session.email === details.login || policyMember.role === CONST.POLICY.ROLE.ADMIN; result.push({ - keyForList: accountID, + keyForList: accountIDKey, accountID: accountID, isSelected: _.contains(selectedEmployees, accountID), isDisabled: From f8cf28b2d437bcbb31a28c5b28c5990ef3d4c92a Mon Sep 17 00:00:00 2001 From: someone-here Date: Thu, 12 Oct 2023 15:55:07 +0530 Subject: [PATCH 3/6] Fix lint --- src/pages/workspace/WorkspaceMembersPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 52793599dd35..2d6811c81359 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -315,7 +315,7 @@ function WorkspaceMembersPage(props) { result.push({ keyForList: accountIDKey, - accountID: accountID, + accountID, isSelected: _.contains(selectedEmployees, accountID), isDisabled: accountID === props.session.accountID || From 36409d39e6296e31b1889c6d7b266f686a5926d7 Mon Sep 17 00:00:00 2001 From: someone-here Date: Fri, 13 Oct 2023 17:40:26 +0530 Subject: [PATCH 4/6] Convert accountID to number --- src/libs/PolicyUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 347a825f59cc..6bbae72f1d80 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -174,7 +174,7 @@ function getMemberAccountIDsForWorkspace(policyMembers, personalDetails) { if (!personalDetail || !personalDetail.login) { return; } - memberEmailsToAccountIDs[personalDetail.login] = accountID; + memberEmailsToAccountIDs[personalDetail.login] = Number(accountID); }); return memberEmailsToAccountIDs; } From 551348300994f52048dbec3eba1ff4fd41b9dda8 Mon Sep 17 00:00:00 2001 From: someone-here Date: Fri, 13 Oct 2023 18:13:45 +0530 Subject: [PATCH 5/6] convert accountIDs to Number --- src/pages/workspace/WorkspaceMembersPage.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 2d6811c81359..07423364d060 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -76,7 +76,7 @@ function WorkspaceMembersPage(props) { const [errors, setErrors] = useState({}); const [searchValue, setSearchValue] = useState(''); const prevIsOffline = usePrevious(props.network.isOffline); - const accountIDs = useMemo(() => _.keys(props.policyMembers), [props.policyMembers]); + const accountIDs = useMemo(() => _.map(_.keys(props.policyMembers), (accountID) => Number(accountID)), [props.policyMembers]); const prevAccountIDs = usePrevious(accountIDs); const textInputRef = useRef(null); const isOfflineAndNoMemberDataAvailable = _.isEmpty(props.policyMembers) && props.network.isOffline; @@ -119,7 +119,7 @@ function WorkspaceMembersPage(props) { setSelectedEmployees((prevSelected) => _.intersection( prevSelected, - _.map(_.values(PolicyUtils.getMemberAccountIDsForWorkspace(props.policyMembers, props.personalDetails)), (accountID) => Number(accountID)), + _.values(PolicyUtils.getMemberAccountIDsForWorkspace(props.policyMembers, props.personalDetails)), ), ); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -173,12 +173,12 @@ function WorkspaceMembersPage(props) { */ const toggleAllUsers = (memberList) => { const enabledAccounts = _.filter(memberList, (member) => !member.isDisabled); - const everyoneSelected = _.every(enabledAccounts, (member) => _.contains(selectedEmployees, Number(member.keyForList))); + const everyoneSelected = _.every(enabledAccounts, (member) => _.contains(selectedEmployees, member.accountID)); if (everyoneSelected) { setSelectedEmployees([]); } else { - const everyAccountId = _.map(enabledAccounts, (member) => Number(member.keyForList)); + const everyAccountId = _.map(enabledAccounts, (member) => member.accountID); setSelectedEmployees(everyAccountId); } @@ -225,10 +225,10 @@ function WorkspaceMembersPage(props) { } // Add or remove the user if the checkbox is enabled - if (_.contains(selectedEmployees, Number(accountID))) { - removeUser(Number(accountID)); + if (_.contains(selectedEmployees, accountID)) { + removeUser(accountID); } else { - addUser(Number(accountID)); + addUser(accountID); } }, [selectedEmployees, addUser, removeUser], @@ -418,7 +418,7 @@ function WorkspaceMembersPage(props) { textInputValue={searchValue} onChangeText={setSearchValue} headerMessage={getHeaderMessage()} - onSelectRow={(item) => toggleUser(item.keyForList)} + onSelectRow={(item) => toggleUser(item.accountID)} onSelectAll={() => toggleAllUsers(data)} onDismissError={dismissError} showLoadingPlaceholder={!isOfflineAndNoMemberDataAvailable && (!OptionsListUtils.isPersonalDetailsReady(props.personalDetails) || _.isEmpty(props.policyMembers))} From 5fb957cef2ee975ac86195d6203a8f4cf73e849b Mon Sep 17 00:00:00 2001 From: someone-here Date: Fri, 13 Oct 2023 18:15:40 +0530 Subject: [PATCH 6/6] Fix lint --- src/pages/workspace/WorkspaceMembersPage.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 07423364d060..fb394721ff3c 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -116,12 +116,7 @@ function WorkspaceMembersPage(props) { if (removeMembersConfirmModalVisible && !_.isEqual(accountIDs, prevAccountIDs)) { setRemoveMembersConfirmModalVisible(false); } - setSelectedEmployees((prevSelected) => - _.intersection( - prevSelected, - _.values(PolicyUtils.getMemberAccountIDsForWorkspace(props.policyMembers, props.personalDetails)), - ), - ); + setSelectedEmployees((prevSelected) => _.intersection(prevSelected, _.values(PolicyUtils.getMemberAccountIDsForWorkspace(props.policyMembers, props.personalDetails)))); // eslint-disable-next-line react-hooks/exhaustive-deps }, [props.policyMembers]);