@@ -97,6 +97,7 @@ import getStateFromPath from './Navigation/helpers/getStateFromPath';
9797import { isFullScreenName } from './Navigation/helpers/isNavigatorName' ;
9898import { linkingConfig } from './Navigation/linkingConfig' ;
9999import Navigation , { navigationRef } from './Navigation/Navigation' ;
100+ import type { MoneyRequestNavigatorParamList , ReportsSplitNavigatorParamList } from './Navigation/types' ;
100101import { rand64 } from './NumberUtils' ;
101102import Parser from './Parser' ;
102103import { getParsedMessageWithShortMentions } from './ParsingUtils' ;
@@ -9974,18 +9975,24 @@ function isReportOutstanding(
99749975 iouReport : OnyxInputOrEntry < Report > ,
99759976 policyID : string | undefined ,
99769977 reportNameValuePairs : OnyxCollection < ReportNameValuePairs > = allReportNameValuePair ,
9978+ allowSubmitted = true ,
99779979) : boolean {
99789980 if ( ! iouReport || isEmptyObject ( iouReport ) ) {
99799981 return false ;
99809982 }
9983+ const currentRoute = navigationRef . getCurrentRoute ( ) ;
9984+ const params = currentRoute ?. params as MoneyRequestNavigatorParamList [ typeof SCREENS . MONEY_REQUEST . STEP_CONFIRMATION ] | ReportsSplitNavigatorParamList [ typeof SCREENS . REPORT ] ;
9985+ const activeReport = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ params ?. reportID } ` ] ;
9986+ const policy = allPolicies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` ] ;
99819987 const reportNameValuePair = reportNameValuePairs ?. [ `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ iouReport . reportID } ` ] ;
9988+ const shouldAllowSubmittedReport = allowSubmitted || isInstantSubmitEnabled ( policy ) || isProcessingReport ( activeReport ) ;
99829989 return (
99839990 isExpenseReport ( iouReport ) &&
99849991 iouReport ?. stateNum !== undefined &&
99859992 iouReport ?. statusNum !== undefined &&
99869993 iouReport ?. policyID === policyID &&
9987- iouReport ?. stateNum <= CONST . REPORT . STATE_NUM . SUBMITTED &&
9988- iouReport ?. statusNum <= CONST . REPORT . STATUS_NUM . SUBMITTED &&
9994+ ( shouldAllowSubmittedReport ? iouReport ?. stateNum <= CONST . REPORT . STATE_NUM . SUBMITTED : iouReport ?. stateNum < CONST . REPORT . STATE_NUM . SUBMITTED ) &&
9995+ ( shouldAllowSubmittedReport ? iouReport ?. statusNum <= CONST . REPORT . STATE_NUM . SUBMITTED : iouReport ?. statusNum < CONST . REPORT . STATE_NUM . SUBMITTED ) &&
99899996 ! hasForwardedAction ( iouReport . reportID ) &&
99909997 ! isArchivedReport ( reportNameValuePair )
99919998 ) ;
@@ -10003,6 +10010,7 @@ function getOutstandingReportsForUser(
1000310010 reportOwnerAccountID : number | undefined ,
1000410011 reports : OnyxCollection < Report > = allReports ,
1000510012 reportNameValuePairs : OnyxCollection < ReportNameValuePairs > = allReportNameValuePair ,
10013+ allowSubmitted = true ,
1000610014) : Array < OnyxEntry < Report > > {
1000710015 if ( ! reports ) {
1000810016 return [ ] ;
@@ -10011,7 +10019,7 @@ function getOutstandingReportsForUser(
1001110019 . filter (
1001210020 ( report ) =>
1001310021 report ?. pendingFields ?. preview !== CONST . RED_BRICK_ROAD_PENDING_ACTION . DELETE &&
10014- isReportOutstanding ( report , policyID , reportNameValuePairs ) &&
10022+ isReportOutstanding ( report , policyID , reportNameValuePairs , allowSubmitted ) &&
1001510023 report ?. ownerAccountID === reportOwnerAccountID ,
1001610024 )
1001710025 . sort ( ( a , b ) => localeCompare ( a ?. reportName ?. toLowerCase ( ) ?? '' , b ?. reportName ?. toLowerCase ( ) ?? '' ) ) ;
0 commit comments