From 7a4cb93cb004aa85a69962caeaeeba9d3fa37ceb Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 25 Nov 2024 15:45:22 +0700 Subject: [PATCH 1/4] fix: Header - Approve button appears briefly when it shouldn't --- src/libs/actions/IOU.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 10eee66428e8..b2e173ed0b26 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7190,6 +7190,8 @@ function submitReport(expenseReport: OnyxTypes.Report) { const adminAccountID = policy?.role === CONST.POLICY.ROLE.ADMIN ? currentUserPersonalDetails?.accountID : undefined; const optimisticSubmittedReportAction = ReportUtils.buildOptimisticSubmittedReportAction(expenseReport?.total ?? 0, expenseReport.currency ?? '', expenseReport.reportID, adminAccountID); const optimisticNextStep = NextStepUtils.buildNextStep(expenseReport, isSubmitAndClosePolicy ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.SUBMITTED); + const approvalChain = ReportUtils.getApprovalChain(PolicyUtils.getPolicy(expenseReport?.policyID), expenseReport); + const managerID = approvalChain.at(0); const optimisticData: OnyxUpdate[] = !isSubmitAndClosePolicy ? [ @@ -7208,6 +7210,7 @@ function submitReport(expenseReport: OnyxTypes.Report) { key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, value: { ...expenseReport, + managerID, lastMessageText: ReportActionsUtils.getReportActionText(optimisticSubmittedReportAction), lastMessageHtml: ReportActionsUtils.getReportActionHtml(optimisticSubmittedReportAction), stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, From feffdeedf02fc84acadd54972a0d50baf3755711 Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 25 Nov 2024 18:43:16 +0700 Subject: [PATCH 2/4] fix prettier --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b2e173ed0b26..6710823df16a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7191,7 +7191,7 @@ function submitReport(expenseReport: OnyxTypes.Report) { const optimisticSubmittedReportAction = ReportUtils.buildOptimisticSubmittedReportAction(expenseReport?.total ?? 0, expenseReport.currency ?? '', expenseReport.reportID, adminAccountID); const optimisticNextStep = NextStepUtils.buildNextStep(expenseReport, isSubmitAndClosePolicy ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.SUBMITTED); const approvalChain = ReportUtils.getApprovalChain(PolicyUtils.getPolicy(expenseReport?.policyID), expenseReport); - const managerID = approvalChain.at(0); + const managerID = approvalChain.length ? Number(approvalChain.at(0)) : undefined; const optimisticData: OnyxUpdate[] = !isSubmitAndClosePolicy ? [ From 021d78410cffe51bb367e0fa78243547e8105c2c Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 2 Dec 2024 18:48:10 +0700 Subject: [PATCH 3/4] fix: get manager ID from approval chain --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 6710823df16a..97bd96c61212 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7191,7 +7191,7 @@ function submitReport(expenseReport: OnyxTypes.Report) { const optimisticSubmittedReportAction = ReportUtils.buildOptimisticSubmittedReportAction(expenseReport?.total ?? 0, expenseReport.currency ?? '', expenseReport.reportID, adminAccountID); const optimisticNextStep = NextStepUtils.buildNextStep(expenseReport, isSubmitAndClosePolicy ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.SUBMITTED); const approvalChain = ReportUtils.getApprovalChain(PolicyUtils.getPolicy(expenseReport?.policyID), expenseReport); - const managerID = approvalChain.length ? Number(approvalChain.at(0)) : undefined; + const managerID = PersonalDetailsUtils.getAccountIDsByLogins(approvalChain).at(0); const optimisticData: OnyxUpdate[] = !isSubmitAndClosePolicy ? [ From 0537b119b6afadaf30990582228db66cbe36688f Mon Sep 17 00:00:00 2001 From: daledah Date: Wed, 4 Dec 2024 16:27:02 +0700 Subject: [PATCH 4/4] fix: remove duplicate code --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 97bd96c61212..a627f0f53d32 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7190,7 +7190,7 @@ function submitReport(expenseReport: OnyxTypes.Report) { const adminAccountID = policy?.role === CONST.POLICY.ROLE.ADMIN ? currentUserPersonalDetails?.accountID : undefined; const optimisticSubmittedReportAction = ReportUtils.buildOptimisticSubmittedReportAction(expenseReport?.total ?? 0, expenseReport.currency ?? '', expenseReport.reportID, adminAccountID); const optimisticNextStep = NextStepUtils.buildNextStep(expenseReport, isSubmitAndClosePolicy ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.SUBMITTED); - const approvalChain = ReportUtils.getApprovalChain(PolicyUtils.getPolicy(expenseReport?.policyID), expenseReport); + const approvalChain = ReportUtils.getApprovalChain(policy, expenseReport); const managerID = PersonalDetailsUtils.getAccountIDsByLogins(approvalChain).at(0); const optimisticData: OnyxUpdate[] = !isSubmitAndClosePolicy