diff --git a/src/components/ReportActionItem/MoneyReportView.tsx b/src/components/ReportActionItem/MoneyReportView.tsx index 5b8961ec512a..e3144af55675 100644 --- a/src/components/ReportActionItem/MoneyReportView.tsx +++ b/src/components/ReportActionItem/MoneyReportView.tsx @@ -128,7 +128,7 @@ function MoneyReportView({ (reportField) => !isReportFieldDisabled(report, reportField, policy) || reportField.type === CONST.REPORT_FIELD_TYPES.FORMULA, ); const isOnlyTitleFieldEnabled = enabledReportFields.length === 1 && isReportFieldOfTypeTitle(enabledReportFields.at(0)); - const isClosedExpenseReportWithNoExpenses = isClosedExpenseReportWithNoExpensesReportUtils(report); + const isClosedExpenseReportWithNoExpenses = isClosedExpenseReportWithNoExpensesReportUtils(report, transactions); const isPaidGroupPolicyExpenseReport = isPaidGroupPolicyExpenseReportUtils(report); const isInvoiceReport = isInvoiceReportUtils(report); diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts index e8e5b7651d2c..4948b9da6ff7 100644 --- a/src/libs/ReportNameUtils.ts +++ b/src/libs/ReportNameUtils.ts @@ -940,7 +940,7 @@ function computeReportName({ return chatThreadReportName; } - const transactionsArray = transactions ? (Object.values(transactions).filter(Boolean) as Array>) : undefined; + const transactionsArray = transactions ? (Object.values(transactions).filter(Boolean) as Array>) : []; if (isClosedExpenseReportWithNoExpenses(report, transactionsArray)) { // eslint-disable-next-line @typescript-eslint/no-deprecated return translateLocal('parentReportAction.deletedReport'); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 4f44b20ab5af..e9de4d1791e3 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2330,17 +2330,14 @@ function findLastAccessedReport(ignoreDomainRooms: boolean, openOnAdminRoom = fa /** * Whether the provided report has expenses */ -function hasExpenses(reportID?: string, transactions?: Array>): boolean { - if (transactions) { - return !!transactions?.find((transaction) => transaction?.reportID === reportID); - } - return !!Object.values(deprecatedAllTransactions ?? {}).find((transaction) => transaction?.reportID === reportID); +function hasExpenses(reportID: string | undefined, transactions: Array>): boolean { + return !!transactions.find((transaction) => transaction?.reportID === reportID); } /** * Whether the provided report is a closed expense report with no expenses */ -function isClosedExpenseReportWithNoExpenses(report: OnyxEntry, transactions?: Array>): boolean { +function isClosedExpenseReportWithNoExpenses(report: OnyxEntry, transactions: Array>): boolean { if (!report?.statusNum || report.statusNum !== CONST.REPORT.STATUS_NUM.CLOSED || !isExpenseReport(report)) { return false; } @@ -5928,7 +5925,7 @@ function getReportName(reportNameInformation: GetReportNameParams): string { return reportActionMessage; } - if (isClosedExpenseReportWithNoExpenses(report, transactions)) { + if (isClosedExpenseReportWithNoExpenses(report, transactions ?? [])) { // eslint-disable-next-line @typescript-eslint/no-deprecated return translateLocal('parentReportAction.deletedReport'); } diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 0b40513c261b..8fb0b510edd7 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -2548,7 +2548,7 @@ describe('ReportUtils', () => { }; // Then it should not be considered closed without expenses, because it has a total - expect(isClosedExpenseReportWithNoExpenses(expenseReport)).toBe(false); + expect(isClosedExpenseReportWithNoExpenses(expenseReport, [])).toBe(false); }); test('closed expense report with zero total but non-reimbursable total exists', () => { @@ -2562,7 +2562,7 @@ describe('ReportUtils', () => { }; // Then it should not be considered closed without expenses, because nonReimbursableTotal indicates expenses exist - expect(isClosedExpenseReportWithNoExpenses(expenseReport)).toBe(false); + expect(isClosedExpenseReportWithNoExpenses(expenseReport, [])).toBe(false); }); test('should handle paid elsewhere money request', () => {