@@ -55,6 +55,8 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
55
55
const [ searchValue , setSearchValue ] = useState ( '' ) ;
56
56
const [ didLoadRoomMembers , setDidLoadRoomMembers ] = useState ( false ) ;
57
57
const personalDetails = usePersonalDetails ( ) || CONST . EMPTY_OBJECT ;
58
+ const policy = useMemo ( ( ) => policies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ report ?. policyID ?? '' } ` ] , [ policies , report ?. policyID ] ) ;
59
+ const isPolicyExpenseChat = useMemo ( ( ) => ReportUtils . isPolicyExpenseChat ( report ) , [ report ] ) ;
58
60
59
61
const isFocusedScreen = useIsFocused ( ) ;
60
62
@@ -196,31 +198,33 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) {
196
198
memberDetails += ` ${ details . phoneNumber . toLowerCase ( ) } ` ;
197
199
}
198
200
199
- if ( ! OptionsListUtils . isSearchStringMatch ( searchValue . trim ( ) , memberDetails ) ) {
200
- return ;
201
+ if ( ! OptionsListUtils . isSearchStringMatch ( searchValue . trim ( ) , memberDetails ) ) {
202
+ return ;
203
+ }
201
204
}
202
- }
203
- const pendingChatMember = report ?. pendingChatMembers ?. findLast ( ( member ) => member . accountID === accountID . toString ( ) ) ;
205
+ const pendingChatMember = report ?. pendingChatMembers ?. findLast ( ( member ) => member . accountID === accountID . toString ( ) ) ;
206
+ const isAdmin = ! ! ( policy && policy . employeeList && details . login && policy . employeeList [ details . login ] ?. role === CONST . POLICY . ROLE . ADMIN ) ;
207
+ const isDisabled = ( isPolicyExpenseChat && isAdmin ) || accountID === session ?. accountID || pendingChatMember ?. pendingAction === CONST . RED_BRICK_ROAD_PENDING_ACTION . DELETE ;
204
208
205
- result . push ( {
206
- keyForList : String ( accountID ) ,
207
- accountID,
208
- isSelected : selectedMembers . includes ( accountID ) ,
209
- isDisabled : accountID === session ?. accountID || pendingChatMember ?. pendingAction === CONST . RED_BRICK_ROAD_PENDING_ACTION . DELETE ,
210
- text : formatPhoneNumber ( PersonalDetailsUtils . getDisplayNameOrDefault ( details ) ) ,
211
- alternateText : details ?. login ? formatPhoneNumber ( details . login ) : '' ,
212
- icons : [
213
- {
214
- source : details . avatar ?? FallbackAvatar ,
215
- name : details . login ?? '' ,
216
- type : CONST . ICON_TYPE_AVATAR ,
217
- id : accountID ,
218
- } ,
219
- ] ,
220
- pendingAction : pendingChatMember ?. pendingAction ,
221
- errors : pendingChatMember ?. errors ,
209
+ result . push ( {
210
+ keyForList : String ( accountID ) ,
211
+ accountID,
212
+ isSelected : selectedMembers . includes ( accountID ) ,
213
+ isDisabled,
214
+ text : formatPhoneNumber ( PersonalDetailsUtils . getDisplayNameOrDefault ( details ) ) ,
215
+ alternateText : details ?. login ? formatPhoneNumber ( details . login ) : '' ,
216
+ icons : [
217
+ {
218
+ source : details . avatar ?? FallbackAvatar ,
219
+ name : details . login ?? '' ,
220
+ type : CONST . ICON_TYPE_AVATAR ,
221
+ id : accountID ,
222
+ } ,
223
+ ] ,
224
+ pendingAction : pendingChatMember ?. pendingAction ,
225
+ errors : pendingChatMember ?. errors ,
226
+ } ) ;
222
227
} ) ;
223
- } ) ;
224
228
225
229
result = result . sort ( ( value1 , value2 ) => localeCompare ( value1 . text ?? '' , value2 . text ?? '' ) ) ;
226
230
0 commit comments