diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c049052d89ae9..a7dd3b80ba40e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -11355,25 +11355,28 @@ function isReportOutstanding( reportNameValuePairs: OnyxCollection = allReportNameValuePair, allowSubmitted = true, ): boolean { - if (!iouReport || isEmptyObject(iouReport)) { + if ( + !iouReport || + isEmptyObject(iouReport) || + !isExpenseReport(iouReport) || + iouReport?.stateNum === undefined || + iouReport?.statusNum === undefined || + iouReport?.policyID !== policyID || + hasForwardedAction(iouReport.reportID) + ) { + return false; + } + const reportNameValuePair = reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport.reportID}`]; + if (isArchivedReport(reportNameValuePair)) { return false; } const currentRoute = navigationRef.getCurrentRoute(); const params = currentRoute?.params as MoneyRequestNavigatorParamList[typeof SCREENS.MONEY_REQUEST.STEP_CONFIRMATION] | ReportsSplitNavigatorParamList[typeof SCREENS.REPORT]; const activeReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${params?.reportID}`]; - const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]; - const reportNameValuePair = reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReport.reportID}`]; - const shouldAllowSubmittedReport = allowSubmitted || isInstantSubmitEnabled(policy) || isProcessingReport(activeReport); - return ( - isExpenseReport(iouReport) && - iouReport?.stateNum !== undefined && - iouReport?.statusNum !== undefined && - iouReport?.policyID === policyID && - (shouldAllowSubmittedReport ? iouReport?.stateNum <= CONST.REPORT.STATE_NUM.SUBMITTED : iouReport?.stateNum < CONST.REPORT.STATE_NUM.SUBMITTED) && - (shouldAllowSubmittedReport ? iouReport?.statusNum <= CONST.REPORT.STATE_NUM.SUBMITTED : iouReport?.statusNum < CONST.REPORT.STATE_NUM.SUBMITTED) && - !hasForwardedAction(iouReport.reportID) && - !isArchivedReport(reportNameValuePair) - ); + if (allowSubmitted || isProcessingReport(activeReport) || canAddTransaction(iouReport, false, false)) { + return iouReport.stateNum <= CONST.REPORT.STATE_NUM.SUBMITTED && iouReport.statusNum <= CONST.REPORT.STATE_NUM.SUBMITTED; + } + return iouReport.stateNum < CONST.REPORT.STATE_NUM.SUBMITTED && iouReport.statusNum < CONST.REPORT.STATE_NUM.SUBMITTED; } /**