From e89c19134cf2e3e13945910a5464130adb8dffaf Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Fri, 12 Jan 2024 00:30:47 +0000 Subject: [PATCH 1/2] Set the manager optimistically if possible --- src/libs/ReportUtils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 1010f8bd82e0..529821996530 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -110,6 +110,7 @@ type OptimisticExpenseReport = Pick< | 'policyID' | 'type' | 'ownerAccountID' + | 'managerID' | 'currency' | 'reportName' | 'state' @@ -2592,7 +2593,7 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa const stateNum = isFree ? CONST.REPORT.STATE_NUM.PROCESSING : CONST.REPORT.STATE_NUM.OPEN; const statusNum = isFree ? CONST.REPORT.STATUS.SUBMITTED : CONST.REPORT.STATUS.OPEN; - return { + const expenseReport: OptimisticExpenseReport = { reportID: generateReportID(), chatReportID, policyID, @@ -2610,6 +2611,12 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa parentReportID: chatReportID, lastVisibleActionCreated: DateUtils.getDBTime(), }; + + if (policy?.submitsTo) { + expenseReport.managerID = policy.submitsTo; + } + + return expenseReport; } /** From 67ab1187fd2150a83bfb9f3211823dd5ee899b60 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Fri, 12 Jan 2024 00:31:19 +0000 Subject: [PATCH 2/2] Add descriptive comment --- src/libs/ReportUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 529821996530..da16a337ee99 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2612,6 +2612,7 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa lastVisibleActionCreated: DateUtils.getDBTime(), }; + // The account defined in the policy submitsTo field is the approver/ manager for this report if (policy?.submitsTo) { expenseReport.managerID = policy.submitsTo; }