diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0f0dffd93f7e..7f26566e041d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7188,7 +7188,11 @@ function shouldDisplayViolationsRBRInLHN(report: OnyxEntry, 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) + ); }); } diff --git a/tests/unit/DebugUtilsTest.ts b/tests/unit/DebugUtilsTest.ts index f95fe9912a91..7dfde9d4cab6 100644 --- a/tests/unit/DebugUtilsTest.ts +++ b/tests/unit/DebugUtilsTest.ts @@ -1577,6 +1577,7 @@ describe('DebugUtils', () => { { type: CONST.VIOLATION_TYPES.VIOLATION, name: CONST.VIOLATIONS.MISSING_CATEGORY, + showInReview: true, }, ], }); diff --git a/tests/unit/SidebarUtilsTest.ts b/tests/unit/SidebarUtilsTest.ts index c5697f8385c6..84810aaad735 100644 --- a/tests/unit/SidebarUtilsTest.ts +++ b/tests/unit/SidebarUtilsTest.ts @@ -60,6 +60,7 @@ describe('SidebarUtils', () => { { type: CONST.VIOLATION_TYPES.VIOLATION, name: CONST.VIOLATIONS.MISSING_CATEGORY, + showInReview: true, }, ], }; @@ -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); + + 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, }, ], }; diff --git a/tests/unit/WorkspaceSettingsUtilsTest.json b/tests/unit/WorkspaceSettingsUtilsTest.json index 52048f5efccb..2bde45c62d91 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.json +++ b/tests/unit/WorkspaceSettingsUtilsTest.json @@ -42,13 +42,15 @@ "transactionViolations_3106135972713435169": [ { "name": "missingCategory", - "type": "violation" + "type": "violation", + "showInReview": true } ], "transactionViolations_3690687111940510713": [ { "name": "missingCategory", - "type": "violation" + "type": "violation", + "showInReview": true } ] },