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
2 changes: 1 addition & 1 deletion 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 hasViolations = canUseViolations && ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction ?? null);
FitseTLT marked this conversation as resolved.
Show resolved Hide resolved

const optionItem = useMemo(() => {
// Note: ideally we'd have this as a dependent selector in onyx!
Expand Down
19 changes: 19 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4155,9 +4155,27 @@ function doesTransactionThreadHaveViolations(report: OnyxEntry<Report>, transact
if (report?.stateNum !== CONST.REPORT.STATE_NUM.OPEN && report?.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED) {
return false;
}

FitseTLT marked this conversation as resolved.
Show resolved Hide resolved
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 {
if (parentReportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU) {
return false;
}
FitseTLT marked this conversation as resolved.
Show resolved Hide resolved

const {IOUReportID} = parentReportAction.originalMessage ?? {};

return doesTransactionThreadHaveViolations(report, transactionViolations, parentReportAction) && !isSettled(IOUReportID);
FitseTLT marked this conversation as resolved.
Show resolved Hide resolved
}

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