Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11355,25 +11355,28 @@ function isReportOutstanding(
reportNameValuePairs: OnyxCollection<ReportNameValuePairs> = 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;
}

/**
Expand Down
Loading