From a2aeb0fe759c6cd55a5a7c894cba21cde9d01f6f Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 12 Dec 2024 13:49:05 +0100 Subject: [PATCH 1/4] use reportName for invoice report --- src/libs/ReportUtils.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a30de7b97198..0b848eb06cbd 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4066,11 +4066,7 @@ function getReportName( } if (isInvoiceReport(report)) { - if (!isInvoiceRoom(getReport(report?.chatReportID ?? ''))) { - return report?.reportName ?? getMoneyRequestReportName(report, policy, invoiceReceiverPolicy); - } - - formattedName = getMoneyRequestReportName(report, policy, invoiceReceiverPolicy); + formattedName = report?.reportName ?? getMoneyRequestReportName(report, policy, invoiceReceiverPolicy); } if (isInvoiceRoom(report)) { From e5a3a45fd874a729970a655c5b5f155ce38ae610 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Mon, 16 Dec 2024 12:55:11 +0100 Subject: [PATCH 2/4] update invoice report name format to include date instead of total --- src/libs/ReportUtils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2f4956fb7cb5..b3163da69cd3 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4643,8 +4643,6 @@ function populateOptimisticReportFormula(formula: string, report: OptimisticExpe /** Builds an optimistic invoice report with a randomly generated reportID */ function buildOptimisticInvoiceReport(chatReportID: string, policyID: string, receiverAccountID: number, receiverName: string, total: number, currency: string): OptimisticExpenseReport { - const formattedTotal = CurrencyUtils.convertToDisplayString(total, currency); - return { reportID: generateReportID(), chatReportID, @@ -4654,7 +4652,7 @@ function buildOptimisticInvoiceReport(chatReportID: string, policyID: string, re managerID: receiverAccountID, currency, // We don’t translate reportName because the server response is always in English - reportName: `${receiverName} owes ${formattedTotal}`, + reportName: `Invoice ${DateUtils.extractDate(new Date().toString())}`, stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, statusNum: CONST.REPORT.STATUS_NUM.OPEN, total, From 668dcdfc47d71dae7da775ba3c66fcb010c1785f Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 17 Dec 2024 17:05:24 +0100 Subject: [PATCH 3/4] Revert "update invoice report name format to include date instead of total" This reverts commit e5a3a45fd874a729970a655c5b5f155ce38ae610. --- src/libs/ReportUtils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b3163da69cd3..2f4956fb7cb5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4643,6 +4643,8 @@ function populateOptimisticReportFormula(formula: string, report: OptimisticExpe /** Builds an optimistic invoice report with a randomly generated reportID */ function buildOptimisticInvoiceReport(chatReportID: string, policyID: string, receiverAccountID: number, receiverName: string, total: number, currency: string): OptimisticExpenseReport { + const formattedTotal = CurrencyUtils.convertToDisplayString(total, currency); + return { reportID: generateReportID(), chatReportID, @@ -4652,7 +4654,7 @@ function buildOptimisticInvoiceReport(chatReportID: string, policyID: string, re managerID: receiverAccountID, currency, // We don’t translate reportName because the server response is always in English - reportName: `Invoice ${DateUtils.extractDate(new Date().toString())}`, + reportName: `${receiverName} owes ${formattedTotal}`, stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, statusNum: CONST.REPORT.STATUS_NUM.OPEN, total, From 95e62762ee743327fd6d113fc30723bf656285bc Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 17 Dec 2024 19:39:39 +0100 Subject: [PATCH 4/4] Enhance optimistic invoice report creation by improving receiver display name fallback logic --- src/libs/actions/IOU.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 696853f49fd7..1a3f4b501e78 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2097,7 +2097,14 @@ function getSendInvoiceInformation( } // STEP 2: Create a new optimistic invoice report. - const optimisticInvoiceReport = ReportUtils.buildOptimisticInvoiceReport(chatReport.reportID, senderWorkspaceID, receiverAccountID, receiver.displayName ?? '', amount, currency); + const optimisticInvoiceReport = ReportUtils.buildOptimisticInvoiceReport( + chatReport.reportID, + senderWorkspaceID, + receiverAccountID, + receiver.displayName ?? (receiverParticipant as Participant)?.login ?? '', + amount, + currency, + ); // STEP 3: Build optimistic receipt and transaction const receiptObject: Receipt = {};