Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -4246,6 +4246,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)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later, we added more condition (approved reports, not only reimbursed/settled) to hide RBR on the LHN for transaction threads.
#45230

return false;
}
return doesTransactionThreadHaveViolations(report, transactionViolations, parentReportAction);
}

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