diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index a18d2667f1ea..d2565022075a 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -131,13 +131,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_TRAVEL.getRoute(policyID)))), routeName: SCREENS.WORKSPACE.TRAVEL, }, - { - translationKey: 'workspace.common.members', - icon: Expensicons.Users, - action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID)))), - brickRoadIndicator: hasMembersError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, - routeName: SCREENS.WORKSPACE.MEMBERS, - }, { translationKey: 'workspace.common.bankAccount', icon: Expensicons.Bank, @@ -156,13 +149,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)))), routeName: SCREENS.WORKSPACE.WORKFLOWS, }, - { - translationKey: 'workspace.common.members', - icon: Expensicons.Users, - action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID)))), - brickRoadIndicator: hasMembersError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, - routeName: SCREENS.WORKSPACE.MEMBERS, - }, { translationKey: 'workspace.common.categories', icon: Expensicons.Folder, @@ -185,6 +171,13 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r brickRoadIndicator: hasGeneralSettingsError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, routeName: SCREENS.WORKSPACE.PROFILE, }, + { + translationKey: 'workspace.common.members', + icon: Expensicons.Users, + action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID)))), + brickRoadIndicator: hasMembersError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, + routeName: SCREENS.WORKSPACE.MEMBERS, + }, ...(isPaidGroupPolicy && shouldShowProtectedItems ? protectedCollectPolicyMenuItems : []), ...(isFreeGroupPolicy && shouldShowProtectedItems ? protectedFreePolicyMenuItems : []), ]; diff --git a/src/pages/workspace/WorkspaceMembersPage.tsx b/src/pages/workspace/WorkspaceMembersPage.tsx index b43659a776d9..e47bc4a09be4 100644 --- a/src/pages/workspace/WorkspaceMembersPage.tsx +++ b/src/pages/workspace/WorkspaceMembersPage.tsx @@ -86,6 +86,7 @@ function WorkspaceMembersPage({policyMembers, personalDetails, route, policy, se const {translate, formatPhoneNumber, preferredLocale} = useLocalize(); const {isSmallScreenWidth} = useWindowDimensions(); const dropdownButtonRef = useRef(null); + const isPolicyAdmin = PolicyUtils.isPolicyAdmin(policy); /** * Get filtered personalDetails list with current policyMembers @@ -306,7 +307,7 @@ function WorkspaceMembersPage({policyMembers, personalDetails, route, policy, se const isSelected = selectedEmployees.includes(accountID); const isOwner = policy?.owner === details.login; - const isAdmin = session?.email === details.login || policyMember.role === CONST.POLICY.ROLE.ADMIN; + const isAdmin = policyMember.role === CONST.POLICY.ROLE.ADMIN; let roleBadge = null; if (isOwner || isAdmin) { @@ -324,10 +325,11 @@ function WorkspaceMembersPage({policyMembers, personalDetails, route, policy, se accountID, isSelected, isDisabled: - accountID === session?.accountID || - accountID === policy?.ownerAccountID || - policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || - !isEmptyObject(policyMember.errors), + isPolicyAdmin && + (accountID === session?.accountID || + accountID === policy?.ownerAccountID || + policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || + !isEmptyObject(policyMember.errors)), text: formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(details)), alternateText: formatPhoneNumber(details?.login ?? ''), rightElement: roleBadge, @@ -375,16 +377,24 @@ function WorkspaceMembersPage({policyMembers, personalDetails, route, policy, se ); - const getCustomListHeader = () => ( - - - {translate('common.member')} - - - {translate('common.role')} + const getCustomListHeader = () => { + const header = ( + + + {translate('common.member')} + + + {translate('common.role')} + - - ); + ); + + if (isPolicyAdmin) { + return header; + } + + return {header}; + }; const changeUserRole = (role: typeof CONST.POLICY.ROLE.ADMIN | typeof CONST.POLICY.ROLE.USER) => { if (!isEmptyObject(errors)) { @@ -428,33 +438,39 @@ function WorkspaceMembersPage({policyMembers, personalDetails, route, policy, se return options; }; - const getHeaderButtons = () => ( - - {selectedEmployees.length > 0 ? ( - - shouldAlwaysShowDropdownMenu - pressOnEnter - customText={translate('workspace.people.selected', {selectedNumber: selectedEmployees.length})} - buttonSize={CONST.DROPDOWN_BUTTON_SIZE.MEDIUM} - onPress={() => null} - options={getBulkActionsButtonOptions()} - buttonRef={dropdownButtonRef} - style={[isSmallScreenWidth && styles.flexGrow1]} - /> - ) : ( -