Skip to content

Commit

Permalink
Merge pull request #37767 from FitseTLT/fix-showing-RBR-for-settled-t…
Browse files Browse the repository at this point in the history
…ransaction
  • Loading branch information
cead22 authored Mar 21, 2024
2 parents ac177bf + f9f8bb2 commit 715714c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/LHNOptionsList/OptionRowLHNData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function OptionRowLHNData({

const optionItemRef = useRef<OptionData>();

const hasViolations = canUseViolations && ReportUtils.doesTransactionThreadHaveViolations(fullReport, transactionViolations, parentReportAction ?? null);
const shouldDisplayViolations = canUseViolations && ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction ?? null);

const optionItem = useMemo(() => {
// Note: ideally we'd have this as a dependent selector in onyx!
Expand All @@ -48,7 +48,7 @@ function OptionRowLHNData({
preferredLocale: preferredLocale ?? CONST.LOCALES.DEFAULT,
policy,
parentReportAction,
hasViolations: !!hasViolations,
hasViolations: !!shouldDisplayViolations,
});
if (deepEqual(item, optionItemRef.current)) {
return optionItemRef.current;
Expand Down
16 changes: 16 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4250,6 +4250,21 @@ function doesTransactionThreadHaveViolations(report: OnyxEntry<Report>, transact
return TransactionUtils.hasViolation(IOUTransactionID, transactionViolations);
}

/**
* Checks if we should display violation - we display violations when the money request has violation and it is not settled
*/
function shouldDisplayTransactionThreadViolations(
report: OnyxEntry<Report>,
transactionViolations: OnyxCollection<TransactionViolation[]>,
parentReportAction: OnyxEntry<ReportAction>,
): boolean {
const {IOUReportID} = (parentReportAction?.originalMessage as IOUMessage) ?? {};
if (isSettled(IOUReportID)) {
return false;
}
return doesTransactionThreadHaveViolations(report, transactionViolations, parentReportAction);
}

/**
* Checks to see if a report contains a violation
*/
Expand Down Expand Up @@ -5626,6 +5641,7 @@ export {
getRoom,
canEditReportDescription,
doesTransactionThreadHaveViolations,
shouldDisplayTransactionThreadViolations,
hasViolations,
navigateToPrivateNotes,
canEditWriteCapability,
Expand Down

0 comments on commit 715714c

Please sign in to comment.