Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]: {
Expand Down
18 changes: 17 additions & 1 deletion tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
buildOptimisticChatReport,
buildOptimisticCreatedReportAction,
buildOptimisticExpenseReport,
buildOptimisticInvoiceReport,
buildOptimisticIOUReportAction,
buildOptimisticReportPreview,
buildParticipantsFromAccountIDs,
Expand Down Expand Up @@ -1662,7 +1663,7 @@ describe('ReportUtils', () => {
currency: 'USD',
},
};

// eslint-disable-next-line @typescript-eslint/no-deprecated
const transaction: SearchTransaction = {
transactionID: 'txn1',
reportID: '2',
Expand All @@ -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({
Expand Down Expand Up @@ -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();

Expand Down