From 7978db4d158ecefd33512316e87ef0732909e7a0 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 22 Nov 2024 22:44:32 +0300 Subject: [PATCH] fixed RBR logic --- src/components/LHNOptionsList/OptionRowLHNData.tsx | 7 +++++-- src/components/ReportActionItem/ReportPreview.tsx | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHNData.tsx b/src/components/LHNOptionsList/OptionRowLHNData.tsx index 0fe2a1542ca3..ccf12aa4ce24 100644 --- a/src/components/LHNOptionsList/OptionRowLHNData.tsx +++ b/src/components/LHNOptionsList/OptionRowLHNData.tsx @@ -38,7 +38,10 @@ function OptionRowLHNData({ const optionItemRef = useRef(); const shouldDisplayViolations = ReportUtils.shouldDisplayViolationsRBRInLHN(fullReport, transactionViolations); - const shouldDisplayReportViolations = ReportUtils.isReportOwner(fullReport) && ReportUtils.hasReportViolations(reportID); + const isSettled = ReportUtils.isSettled(fullReport); + const shouldDisplayReportViolations = !isSettled && ReportUtils.isReportOwner(fullReport) && ReportUtils.hasReportViolations(reportID); + // We only want to show RBR for expense reports with transaction violations not for transaction threads reports. + const doesExpenseReportHasViolations = ReportUtils.isExpenseReport(fullReport) && !isSettled && ReportUtils.hasViolations(reportID, transactionViolations, true); const optionItem = useMemo(() => { // Note: ideally we'd have this as a dependent selector in onyx! @@ -49,7 +52,7 @@ function OptionRowLHNData({ preferredLocale: preferredLocale ?? CONST.LOCALES.DEFAULT, policy, parentReportAction, - hasViolations: !!shouldDisplayViolations || shouldDisplayReportViolations, + hasViolations: !!shouldDisplayViolations || shouldDisplayReportViolations || doesExpenseReportHasViolations, lastMessageTextFromReport, transactionViolations, invoiceReceiverPolicy, diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 5edeffd4dea4..fcfde2149815 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -344,7 +344,7 @@ function ReportPreview({ const shouldShowSettlementButton = (shouldShowPayButton || shouldShowApproveButton) && !showRTERViolationMessage && !shouldShowBrokenConnectionViolation; const shouldPromptUserToAddBankAccount = ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID) || ReportUtils.hasMissingInvoiceBankAccount(iouReportID); - const shouldShowRBR = hasErrors; + const shouldShowRBR = hasErrors && !iouSettled; /* Show subtitle if at least one of the expenses is not being smart scanned, and either: @@ -492,7 +492,6 @@ function ReportPreview({ fill={theme.danger} /> )} - {!shouldShowRBR && shouldPromptUserToAddBankAccount && (