diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a445cb5b1dad8..a0601c75a27cc 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6592,7 +6592,7 @@ function buildOptimisticInvoiceReport( // We don't translate reportName because the server response is always in English reportName: `${receiverName} owes ${formattedTotal}`, stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, - statusNum: CONST.REPORT.STATUS_NUM.OPEN, + statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, total: total * -1, participants: { [receiverAccountID]: { diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 3d4a79d9e5ea2..25fe39149f70c 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -24,6 +24,7 @@ import { buildOptimisticChatReport, buildOptimisticCreatedReportAction, buildOptimisticExpenseReport, + buildOptimisticInvoiceReport, buildOptimisticIOUReportAction, buildOptimisticReportPreview, buildParticipantsFromAccountIDs, @@ -1662,7 +1663,7 @@ describe('ReportUtils', () => { currency: 'USD', }, }; - + // eslint-disable-next-line @typescript-eslint/no-deprecated const transaction: SearchTransaction = { transactionID: 'txn1', reportID: '2', @@ -1671,6 +1672,7 @@ describe('ReportUtils', () => { merchant: 'Test Merchant', created: testDate, modifiedMerchant: 'Test Merchant', + // eslint-disable-next-line @typescript-eslint/no-deprecated } as SearchTransaction; const reportName = getSearchReportName({ @@ -9410,6 +9412,20 @@ describe('ReportUtils', () => { expect(reason).toBe(CONST.REPORT_IN_LHN_REASONS.DEFAULT); await Onyx.clear(); }); + + it('should create an invoice report with SUBMITTED status the same BE response', () => { + const mockChatReportID = 'chat-report-123'; + const mockPolicyID = 'policy-456'; + const mockReceiverAccountID = 789; + const mockReceiverName = 'John Doe'; + const mockTotal = 100; + const mockCurrency = 'USD'; + const optimisticInvoiceReport = buildOptimisticInvoiceReport(mockChatReportID, mockPolicyID, mockReceiverAccountID, mockReceiverName, mockTotal, mockCurrency); + + expect(optimisticInvoiceReport.statusNum).toBe(CONST.REPORT.STATUS_NUM.SUBMITTED); + expect(optimisticInvoiceReport.stateNum).toBe(CONST.REPORT.STATE_NUM.SUBMITTED); + }); + it('should surface a GBR when copiloted into an approver account with a report with outstanding child request', async () => { await Onyx.clear();