11import { activePolicySelector } from '@selectors/Policy' ;
22import type { OnyxEntry } from 'react-native-onyx' ;
33import { useSession } from '@components/OnyxListItemProvider' ;
4- import { isPaidGroupPolicy , isPolicyAdmin , isPolicyMemberWithoutPendingDelete , isPolicyUser } from '@libs/PolicyUtils' ;
4+ import { getPolicyRole , isPaidGroupPolicy , isPolicyAdmin , isPolicyMemberWithoutPendingDelete , isPolicyUser } from '@libs/PolicyUtils' ;
55import CONST from '@src/CONST' ;
66import ONYXKEYS from '@src/ONYXKEYS' ;
77import type { Policy } from '@src/types/onyx' ;
@@ -16,6 +16,10 @@ function checkForPendingDelete(login: string, policy: OnyxEntry<Policy>) {
1616 return isPolicyMemberWithoutPendingDelete ( login , policy ) ;
1717}
1818
19+ function isPolicyMemberByRole ( login : string , policy : OnyxEntry < Policy > ) {
20+ return isPolicyAdmin ( policy , login ) || isPolicyUser ( policy , login ) || getPolicyRole ( policy , login ) === CONST . POLICY . ROLE . AUDITOR ;
21+ }
22+
1923function usePolicyForMovingExpenses ( ) {
2024 const [ allPolicies ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { canBeMissing : true } ) ;
2125 const [ activePolicyID ] = useOnyx ( ONYXKEYS . NVP_ACTIVE_POLICY_ID , { canBeMissing : true } ) ;
@@ -29,7 +33,7 @@ function usePolicyForMovingExpenses() {
2933 const userPolicies = Object . values ( allPolicies ?? { } ) . filter (
3034 ( policy ) =>
3135 checkForPendingDelete ( login , policy ) &&
32- ( isPolicyAdmin ( policy , login ) || isPolicyUser ( policy , login ) ) &&
36+ isPolicyMemberByRole ( login , policy ) &&
3337 isPaidGroupPolicy ( policy ) &&
3438 policy ?. pendingAction !== CONST . RED_BRICK_ROAD_PENDING_ACTION . DELETE ,
3539 ) ;
0 commit comments