From 9b9ab4950af8f1a3bbddeb34708123536572e8d7 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 3 Mar 2025 23:48:38 +0300 Subject: [PATCH 1/3] add notice type violation for lhn --- src/libs/ReportUtils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index d5c16a6ced03..c08c14567833 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6967,7 +6967,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) + ); }); } From 6d5b5548602becd72a08ff2a76ba41e13d5f1e47 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 5 Mar 2025 15:40:42 +0300 Subject: [PATCH 2/3] fix test --- tests/unit/DebugUtilsTest.ts | 1 + tests/unit/SidebarUtilsTest.ts | 2 ++ tests/unit/WorkspaceSettingsUtilsTest.json | 6 ++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/DebugUtilsTest.ts b/tests/unit/DebugUtilsTest.ts index 1593cb88a630..ab309c4021cb 100644 --- a/tests/unit/DebugUtilsTest.ts +++ b/tests/unit/DebugUtilsTest.ts @@ -1576,6 +1576,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 d3c0d6d7ee61..7102195450ca 100644 --- a/tests/unit/SidebarUtilsTest.ts +++ b/tests/unit/SidebarUtilsTest.ts @@ -59,6 +59,7 @@ describe('SidebarUtils', () => { { type: CONST.VIOLATION_TYPES.VIOLATION, name: CONST.VIOLATIONS.MISSING_CATEGORY, + showInReview: true, }, ], }; @@ -271,6 +272,7 @@ describe('SidebarUtils', () => { { type: CONST.VIOLATION_TYPES.VIOLATION, name: CONST.VIOLATIONS.MISSING_CATEGORY, + 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 } ] }, From 907adaa541c0f3edaa3139137e8ac742adeee433 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 10 Mar 2025 15:43:32 +0300 Subject: [PATCH 3/3] added test --- tests/unit/SidebarUtilsTest.ts | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/unit/SidebarUtilsTest.ts b/tests/unit/SidebarUtilsTest.ts index 7102195450ca..8bfa5b827950 100644 --- a/tests/unit/SidebarUtilsTest.ts +++ b/tests/unit/SidebarUtilsTest.ts @@ -292,6 +292,62 @@ describe('SidebarUtils', () => { 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, + }, + ], + }; + + 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 errors', () => { const MOCK_REPORT: Report = { reportID: '1',