Skip to content

Commit

Permalink
Merge pull request #52988 from FitseTLT/fix-RBR-showing-on-settled-re…
Browse files Browse the repository at this point in the history
…port-previews

Fix - LHN - RBR stays for paid report
  • Loading branch information
grgia authored Nov 27, 2024
2 parents bb74657 + 7978db4 commit f222bfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/components/LHNOptionsList/OptionRowLHNData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ function OptionRowLHNData({
const optionItemRef = useRef<OptionData>();

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!
Expand All @@ -49,7 +52,7 @@ function OptionRowLHNData({
preferredLocale: preferredLocale ?? CONST.LOCALES.DEFAULT,
policy,
parentReportAction,
hasViolations: !!shouldDisplayViolations || shouldDisplayReportViolations,
hasViolations: !!shouldDisplayViolations || shouldDisplayReportViolations || doesExpenseReportHasViolations,
lastMessageTextFromReport,
transactionViolations,
invoiceReceiverPolicy,
Expand Down
3 changes: 1 addition & 2 deletions src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -492,7 +492,6 @@ function ReportPreview({
fill={theme.danger}
/>
)}

{!shouldShowRBR && shouldPromptUserToAddBankAccount && (
<Icon
src={Expensicons.DotIndicator}
Expand Down

0 comments on commit f222bfe

Please sign in to comment.