@@ -7,6 +7,7 @@ import FullscreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
77import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' ;
88import useNetwork from '@hooks/useNetwork' ;
99import useOnyx from '@hooks/useOnyx' ;
10+ import useReportIsArchived from '@hooks/useReportIsArchived' ;
1011import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1112import { openWorkspace } from '@libs/actions/Policy/Policy' ;
1213import { isValidMoneyRequestType } from '@libs/IOUUtils' ;
@@ -31,13 +32,24 @@ const ACCESS_VARIANTS = {
3132 [ CONST . POLICY . ACCESS_VARIANTS . PAID ] : ( policy : OnyxEntry < Policy > ) => isPaidGroupPolicy ( policy ) ,
3233 [ CONST . POLICY . ACCESS_VARIANTS . CONTROL ] : ( policy : OnyxEntry < Policy > ) => isControlPolicy ( policy ) ,
3334 [ CONST . POLICY . ACCESS_VARIANTS . ADMIN ] : ( policy : OnyxEntry < Policy > , login : string ) => isPolicyAdmin ( policy , login ) ,
34- [ CONST . IOU . ACCESS_VARIANTS . CREATE ] : ( policy : OnyxEntry < Policy > , login : string , report : OnyxEntry < Report > , allPolicies : NonNullable < OnyxCollection < Policy > > | null , iouType ?: IOUType ) =>
35+ [ CONST . IOU . ACCESS_VARIANTS . CREATE ] : (
36+ policy : OnyxEntry < Policy > ,
37+ login : string ,
38+ report : OnyxEntry < Report > ,
39+ allPolicies : NonNullable < OnyxCollection < Policy > > | null ,
40+ iouType ?: IOUType ,
41+ isReportArchived ?: boolean ,
42+ ) =>
3543 ! ! iouType &&
3644 isValidMoneyRequestType ( iouType ) &&
3745 // Allow the user to submit the expense if we are submitting the expense in global menu or the report can create the expense
38- ( isEmptyObject ( report ?. reportID ) || canCreateRequest ( report , policy , iouType ) ) &&
46+
47+ ( isEmptyObject ( report ?. reportID ) || canCreateRequest ( report , policy , iouType , isReportArchived ) ) &&
3948 ( iouType !== CONST . IOU . TYPE . INVOICE || canSendInvoice ( allPolicies , login ) ) ,
40- } as const satisfies Record < string , ( policy : Policy , login : string , report : Report , allPolicies : NonNullable < OnyxCollection < Policy > > | null , iouType ?: IOUType ) => boolean > ;
49+ } as const satisfies Record <
50+ string ,
51+ ( policy : Policy , login : string , report : Report , allPolicies : NonNullable < OnyxCollection < Policy > > | null , iouType ?: IOUType , isArchivedReport ?: boolean ) => boolean
52+ > ;
4153
4254type AccessVariant = keyof typeof ACCESS_VARIANTS ;
4355type AccessOrNotFoundWrapperChildrenProps = {
@@ -155,9 +167,10 @@ function AccessOrNotFoundWrapper({
155167
156168 const { isOffline} = useNetwork ( ) ;
157169
170+ const isReportArchived = useReportIsArchived ( report ?. reportID ) ;
158171 const isPageAccessible = accessVariants . reduce ( ( acc , variant ) => {
159172 const accessFunction = ACCESS_VARIANTS [ variant ] ;
160- return acc && accessFunction ( policy , login , report , allPolicies ?? null , iouType ) ;
173+ return acc && accessFunction ( policy , login , report , allPolicies ?? null , iouType , isReportArchived ) ;
161174 } , true ) ;
162175
163176 const isPolicyNotAccessible = ! isPolicyAccessible ( policy ) ;
0 commit comments