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
6 changes: 5 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7188,7 +7188,11 @@ function shouldDisplayViolationsRBRInLHN(report: OnyxEntry<Report>, transactionV
// If any report has a violation, then it should have a RBR
const potentialReports = reportsByPolicyID[report.policyID] ?? [];
return potentialReports.some((potentialReport) => {
return hasViolations(potentialReport.reportID, transactionViolations) || hasWarningTypeViolations(potentialReport.reportID, transactionViolations);
return (
hasViolations(potentialReport.reportID, transactionViolations, true) ||
hasWarningTypeViolations(potentialReport.reportID, transactionViolations, true) ||
hasNoticeTypeViolations(potentialReport.reportID, transactionViolations, true)
);
});
}

Expand Down
1 change: 1 addition & 0 deletions tests/unit/DebugUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,7 @@ describe('DebugUtils', () => {
{
type: CONST.VIOLATION_TYPES.VIOLATION,
name: CONST.VIOLATIONS.MISSING_CATEGORY,
showInReview: true,
},
],
});
Expand Down
58 changes: 58 additions & 0 deletions tests/unit/SidebarUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('SidebarUtils', () => {
{
type: CONST.VIOLATION_TYPES.VIOLATION,
name: CONST.VIOLATIONS.MISSING_CATEGORY,
showInReview: true,
},
],
};
Expand Down Expand Up @@ -311,6 +312,63 @@ describe('SidebarUtils', () => {
{
type: CONST.VIOLATION_TYPES.VIOLATION,
name: CONST.VIOLATIONS.MISSING_CATEGORY,
showInReview: true,
},
],
};

await Onyx.multiSet({
...MOCK_REPORTS,
...MOCK_TRANSACTION_VIOLATIONS,
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${MOCK_REPORT.reportID}` as const]: MOCK_REPORT_ACTIONS,
[ONYXKEYS.SESSION]: {
accountID: 12345,
},
[`${ONYXKEYS.COLLECTION.TRANSACTION}${MOCK_TRANSACTION.transactionID}` as const]: MOCK_TRANSACTION,
});

const result = SidebarUtils.shouldShowRedBrickRoad(MOCK_REPORT, MOCK_REPORT_ACTIONS, false, MOCK_TRANSACTION_VIOLATIONS as OnyxCollection<TransactionViolations>);

expect(result).toBe(true);
});

it('returns true when report has transaction thread notice type violation', async () => {
const MOCK_REPORT: Report = {
reportID: '1',
ownerAccountID: 12345,
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS_NUM.OPEN,
policyID: '6',
};

const MOCK_REPORTS: ReportCollectionDataSet = {
[`${ONYXKEYS.COLLECTION.REPORT}${MOCK_REPORT.reportID}` as const]: MOCK_REPORT,
};

const MOCK_REPORT_ACTIONS: ReportActions = {
// eslint-disable-next-line @typescript-eslint/naming-convention
'1': {
reportActionID: '1',
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
actorAccountID: 12345,
created: '2024-08-08 18:20:44.171',
},
};

const MOCK_TRANSACTION = {
transactionID: '1',
amount: 10,
modifiedAmount: 10,
reportID: MOCK_REPORT.reportID,
};

const MOCK_TRANSACTION_VIOLATIONS: TransactionViolationsCollectionDataSet = {
[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${MOCK_TRANSACTION.transactionID}` as const]: [
{
type: CONST.VIOLATION_TYPES.NOTICE,
name: CONST.VIOLATIONS.MODIFIED_AMOUNT,
showInReview: true,
},
],
};
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/WorkspaceSettingsUtilsTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
"transactionViolations_3106135972713435169": [
{
"name": "missingCategory",
"type": "violation"
"type": "violation",
"showInReview": true
}
],
"transactionViolations_3690687111940510713": [
{
"name": "missingCategory",
"type": "violation"
"type": "violation",
"showInReview": true
}
]
},
Expand Down