Skip to content

Commit

Permalink
took the condition into doesTransactionThreadHaveViolations
Browse files Browse the repository at this point in the history
  • Loading branch information
FitseTLT committed Mar 11, 2024
1 parent 9a0386b commit 3f7a361
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4048,7 +4048,8 @@ function doesTransactionThreadHaveViolations(report: OnyxEntry<Report>, transact
if (report?.stateNum !== CONST.REPORT.STATE_NUM.OPEN && report?.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED) {
return false;
}
return TransactionUtils.hasViolation(IOUTransactionID, transactionViolations);

return TransactionUtils.hasViolation(IOUTransactionID, transactionViolations) && !isSettled(IOUReportID);
}

/**
Expand Down Expand Up @@ -4135,10 +4136,8 @@ function shouldReportBeInOptionList({
return true;
}

const reportIsSettled = report.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;

// Always show IOU reports with violations unless they are reimbursed
if (isExpenseRequest(report) && doesReportHaveViolations && !reportIsSettled) {
// Always show IOU reports with violations
if (isExpenseRequest(report) && doesReportHaveViolations) {
return true;
}

Expand Down
7 changes: 1 addition & 6 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,6 @@ function getOptionData({
const participantPersonalDetailList = Object.values(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails)) as PersonalDetails[];
const personalDetail = participantPersonalDetailList[0] ?? {};
const hasErrors = Object.keys(result.allReportErrors ?? {}).length !== 0;
let shouldShowViolations = false;
if (hasViolations && parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) {
const {IOUReportID} = parentReportAction?.originalMessage ?? {};
shouldShowViolations = !ReportUtils.isSettled(IOUReportID);
}

result.isThread = ReportUtils.isChatThread(report);
result.isChatRoom = ReportUtils.isChatRoom(report);
Expand All @@ -266,7 +261,7 @@ function getOptionData({
result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);
result.shouldShowSubscript = ReportUtils.shouldReportShowSubscript(report);
result.pendingAction = report.pendingFields?.addWorkspaceRoom ?? report.pendingFields?.createChat;
result.brickRoadIndicator = hasErrors || shouldShowViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '';
result.brickRoadIndicator = hasErrors || hasViolations ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '';
result.ownerAccountID = report.ownerAccountID;
result.managerID = report.managerID;
result.reportID = report.reportID;
Expand Down

0 comments on commit 3f7a361

Please sign in to comment.