From 3af8319312fd6f65badd6064bb308f0f3c688532 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Mon, 9 Dec 2024 15:57:59 -0800 Subject: [PATCH] Fix: Remove GBR and 'Add a bank account' for paid invoices --- src/components/ReportActionItem/ReportPreview.tsx | 3 ++- src/libs/ReportUtils.ts | 8 ++++++-- src/pages/home/report/ReportActionItemMessage.tsx | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index badab47b1c35..dcd7d06c3e92 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -346,7 +346,8 @@ function ReportPreview({ const shouldShowSettlementButton = (shouldShowPayButton || shouldShowApproveButton) && !showRTERViolationMessage && !shouldShowBrokenConnectionViolation; - const shouldPromptUserToAddBankAccount = ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID) || ReportUtils.hasMissingInvoiceBankAccount(iouReportID); + const shouldPromptUserToAddBankAccount = + (ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID) || ReportUtils.hasMissingInvoiceBankAccount(iouReportID)) && !ReportUtils.isSettled(iouReportID); const shouldShowRBR = hasErrors && !iouSettled; /* diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9fff3ade23f9..80cc0c462807 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2801,7 +2801,7 @@ function getReasonAndReportActionThatRequiresAttention( }; } - if (hasMissingInvoiceBankAccount(optionOrReport.reportID)) { + if (hasMissingInvoiceBankAccount(optionOrReport.reportID) && !isSettled(optionOrReport.reportID)) { return { reason: CONST.REQUIRES_ATTENTION_REASONS.HAS_MISSING_INVOICE_BANK_ACCOUNT, }; @@ -2809,7 +2809,11 @@ function getReasonAndReportActionThatRequiresAttention( if (isInvoiceRoom(optionOrReport)) { const reportAction = Object.values(reportActions).find( - (action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && action.childReportID && hasMissingInvoiceBankAccount(action.childReportID), + (action) => + action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && + action.childReportID && + hasMissingInvoiceBankAccount(action.childReportID) && + !isSettled(action.childReportID), ); return reportAction diff --git a/src/pages/home/report/ReportActionItemMessage.tsx b/src/pages/home/report/ReportActionItemMessage.tsx index da2f3dd151c8..24dd0d4558ad 100644 --- a/src/pages/home/report/ReportActionItemMessage.tsx +++ b/src/pages/home/report/ReportActionItemMessage.tsx @@ -131,12 +131,14 @@ function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHid Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID)); }; + const shouldShowAddBankAccountButton = action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && ReportUtils.hasMissingInvoiceBankAccount(reportID) && !ReportUtils.isSettled(reportID); + return ( {!isHidden ? ( <> {renderReportActionItemFragments(isApprovedOrSubmittedReportAction)} - {action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && ReportUtils.hasMissingInvoiceBankAccount(reportID) && ( + {shouldShowAddBankAccountButton && (