From 227ea83b450250cbb5a130bd6669dd2cb2033d71 Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 3 Oct 2024 21:56:11 +0700 Subject: [PATCH 1/3] fix: admin cannot open room member details --- src/pages/RoomMembersPage.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/RoomMembersPage.tsx b/src/pages/RoomMembersPage.tsx index f8c07e5b0a67..82b2215b6507 100644 --- a/src/pages/RoomMembersPage.tsx +++ b/src/pages/RoomMembersPage.tsx @@ -166,7 +166,7 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) { /** Add or remove all users passed from the selectedMembers list */ const toggleAllUsers = (memberList: ListItem[]) => { - const enabledAccounts = memberList.filter((member) => !member.isDisabled); + const enabledAccounts = memberList.filter((member) => !member.isDisabled && !member.isDisabledCheckbox); const everyoneSelected = enabledAccounts.every((member) => { if (!member.accountID) { return false; @@ -222,18 +222,19 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) { } const pendingChatMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); const isAdmin = !!(policy && policy.employeeList && details.login && policy.employeeList[details.login]?.role === CONST.POLICY.ROLE.ADMIN); - const isDisabled = + const isDisabled = pendingChatMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || details.isOptimisticPersonalDetail; + const isDisabledCheckbox = (isPolicyExpenseChat && isAdmin) || accountID === session?.accountID || pendingChatMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || - details.accountID === report.ownerAccountID || - details.isOptimisticPersonalDetail; + details.accountID === report.ownerAccountID; result.push({ keyForList: String(accountID), accountID, isSelected: selectedMembers.includes(accountID), isDisabled, + isDisabledCheckbox, text: formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(details)), alternateText: details?.login ? formatPhoneNumber(details.login) : '', icons: [ From 343a1fb91b404e59c57ea2aed30ab84929fc6843 Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 3 Oct 2024 22:14:19 +0700 Subject: [PATCH 2/3] fix lint --- src/pages/RoomMembersPage.tsx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/pages/RoomMembersPage.tsx b/src/pages/RoomMembersPage.tsx index 82b2215b6507..5ea3ad980e7f 100644 --- a/src/pages/RoomMembersPage.tsx +++ b/src/pages/RoomMembersPage.tsx @@ -3,8 +3,7 @@ import {useIsFocused, useRoute} from '@react-navigation/native'; import type {StackScreenProps} from '@react-navigation/stack'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {View} from 'react-native'; -import {useOnyx, withOnyx} from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import Button from '@components/Button'; import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu'; @@ -41,26 +40,19 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import type {Session} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type {WithReportOrNotFoundProps} from './home/report/withReportOrNotFound'; import withReportOrNotFound from './home/report/withReportOrNotFound'; -type RoomMembersPageOnyxProps = { - session: OnyxEntry; -}; +type RoomMembersPageProps = WithReportOrNotFoundProps & WithCurrentUserPersonalDetailsProps & StackScreenProps; -type RoomMembersPageProps = WithReportOrNotFoundProps & - WithCurrentUserPersonalDetailsProps & - RoomMembersPageOnyxProps & - StackScreenProps; - -function RoomMembersPage({report, session, policies}: RoomMembersPageProps) { +function RoomMembersPage({report, policies}: RoomMembersPageProps) { const route = useRoute>(); const styles = useThemeStyles(); const {formatPhoneNumber, translate} = useLocalize(); const [selectedMembers, setSelectedMembers] = useState([]); const [removeMembersConfirmModalVisible, setRemoveMembersConfirmModalVisible] = useState(false); + const [session] = useOnyx(ONYXKEYS.SESSION); const [userSearchPhrase] = useOnyx(ONYXKEYS.ROOM_MEMBERS_USER_SEARCH_PHRASE); const [searchValue, debouncedSearchTerm, setSearchValue] = useDebouncedState(''); const [didLoadRoomMembers, setDidLoadRoomMembers] = useState(false); @@ -410,4 +402,4 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) { RoomMembersPage.displayName = 'RoomMembersPage'; -export default withReportOrNotFound()(withCurrentUserPersonalDetails(withOnyx({session: {key: ONYXKEYS.SESSION}})(RoomMembersPage))); +export default withReportOrNotFound()(withCurrentUserPersonalDetails(RoomMembersPage)); From 7d8b6ba93e059cbf0c251e43732015a46ce6fb1c Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 10 Oct 2024 17:37:04 +0700 Subject: [PATCH 3/3] fix errors --- src/pages/RoomMembersPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/RoomMembersPage.tsx b/src/pages/RoomMembersPage.tsx index e3796d74812e..b5d424b7fc57 100644 --- a/src/pages/RoomMembersPage.tsx +++ b/src/pages/RoomMembersPage.tsx @@ -54,7 +54,6 @@ function RoomMembersPage({report, policies}: RoomMembersPageProps) { const {formatPhoneNumber, translate} = useLocalize(); const [selectedMembers, setSelectedMembers] = useState([]); const [removeMembersConfirmModalVisible, setRemoveMembersConfirmModalVisible] = useState(false); - const [session] = useOnyx(ONYXKEYS.SESSION); const [userSearchPhrase] = useOnyx(ONYXKEYS.ROOM_MEMBERS_USER_SEARCH_PHRASE); const [searchValue, debouncedSearchTerm, setSearchValue] = useDebouncedState(''); const [didLoadRoomMembers, setDidLoadRoomMembers] = useState(false);