Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Don't show RBR on the LHN for transaction threads with violations if the report has already been reimbursed/settled #37767

Merged
Merged
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
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
Loading