@@ -69,11 +69,13 @@ Onyx.connect({
69
69
70
70
/**
71
71
* Filter out the active policies, which will exclude policies with pending deletion
72
+ * and policies the current user doesn't belong to.
72
73
* These are policies that we can use to create reports with in NewDot.
73
74
*/
74
- function getActivePolicies ( policies : OnyxCollection < Policy > | null ) : Policy [ ] {
75
+ function getActivePolicies ( policies : OnyxCollection < Policy > | null , currentUserLogin : string | undefined ) : Policy [ ] {
75
76
return Object . values ( policies ?? { } ) . filter < Policy > (
76
- ( policy ) : policy is Policy => ! ! policy && policy . pendingAction !== CONST . RED_BRICK_ROAD_PENDING_ACTION . DELETE && ! ! policy . name && ! ! policy . id ,
77
+ ( policy ) : policy is Policy =>
78
+ ! ! policy && policy . pendingAction !== CONST . RED_BRICK_ROAD_PENDING_ACTION . DELETE && ! ! policy . name && ! ! policy . id && ! ! getPolicyRole ( policy , currentUserLogin ) ,
77
79
) ;
78
80
}
79
81
/**
@@ -636,7 +638,7 @@ function getPolicy(policyID: string | undefined): OnyxEntry<Policy> {
636
638
637
639
/** Return active policies where current user is an admin */
638
640
function getActiveAdminWorkspaces ( policies : OnyxCollection < Policy > | null , currentUserLogin : string | undefined ) : Policy [ ] {
639
- const activePolicies = getActivePolicies ( policies ) ;
641
+ const activePolicies = getActivePolicies ( policies , currentUserLogin ) ;
640
642
return activePolicies . filter ( ( policy ) => shouldShowPolicy ( policy , NetworkStore . isOffline ( ) , currentUserLogin ) && isPolicyAdmin ( policy , currentUserLogin ) ) ;
641
643
}
642
644
@@ -652,7 +654,7 @@ function canSendInvoice(policies: OnyxCollection<Policy> | null, currentUserLogi
652
654
}
653
655
654
656
function hasWorkspaceWithInvoices ( currentUserLogin : string | undefined ) : boolean {
655
- const activePolicies = getActivePolicies ( allPolicies ) ;
657
+ const activePolicies = getActivePolicies ( allPolicies , currentUserLogin ) ;
656
658
return activePolicies . some ( ( policy ) => shouldShowPolicy ( policy , NetworkStore . isOffline ( ) , currentUserLogin ) && policy . areInvoicesEnabled ) ;
657
659
}
658
660
0 commit comments