From ee0d2e211be2f739d590652ab71ac11634d1eba8 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Wed, 10 Jul 2024 23:31:45 +0700 Subject: [PATCH 1/3] filter paycheck report --- src/CONST.ts | 2 ++ src/libs/ReportUtils.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index b809bdaacaf6..9a682bf247be 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -840,6 +840,8 @@ const CONST = { IOU: 'iou', TASK: 'task', INVOICE: 'invoice', + PAYCHECK: 'paycheck', + BILL: 'bill', }, CHAT_TYPE: chatTypes, WORKSPACE_CHAT_ROOMS: { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0a333b2f1f39..10eec2837fd1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5459,6 +5459,10 @@ function shouldReportBeInOptionList({ return false; } + if (report?.type === CONST.REPORT.TYPE.PAYCHECK || report?.type === CONST.REPORT.TYPE.BILL) { + return false; + } + // Include the currently viewed report. If we excluded the currently viewed report, then there // would be no way to highlight it in the options list and it would be confusing to users because they lose // a sense of context. From d05a5fe88a9ca9b73524c6660f746c5d078e4054 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 11 Jul 2024 00:40:10 +0700 Subject: [PATCH 2/3] add test function --- tests/unit/SidebarFilterTest.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index c54c2cae54f8..23273b7c24b7 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -935,4 +935,33 @@ xdescribe('Sidebar', () => { }); }); }); + + describe('filter paycheck and bill report', () => { + const report1: Report = { + ...LHNTestUtils.getFakeReport(), + type: CONST.REPORT.TYPE.PAYCHECK, + }; + const report2: Report = { + ...LHNTestUtils.getFakeReport(), + type: CONST.REPORT.TYPE.BILL, + }; + const report3: Report = LHNTestUtils.getFakeReport(); + LHNTestUtils.getDefaultRenderedSidebarLinks(report1.reportID); + const reportCollectionDataSet: ReportCollectionDataSet = { + [`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1, + [`${ONYXKEYS.COLLECTION.REPORT}${report2.reportID}`]: report2, + [`${ONYXKEYS.COLLECTION.REPORT}${report3.reportID}`]: report3, + }; + return ( + waitForBatchedUpdates() + .then(() => Onyx.multiSet(reportCollectionDataSet)) + + // Then the reports 1 and 2 are hidden and 3 is not + .then(() => { + const hintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRows = screen.queryAllByAccessibilityHint(hintText); + expect(optionRows).toHaveLength(1); + }) + ); + }); }); From 6152c07358bc79b1892bf62625ac0aeb31ea649f Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 11 Jul 2024 00:45:40 +0700 Subject: [PATCH 3/3] add test function --- tests/unit/SidebarFilterTest.ts | 58 ++++++++++++++++----------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index 23273b7c24b7..1e0745916717 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -280,6 +280,35 @@ xdescribe('Sidebar', () => { ); }); + it('filter paycheck and bill report', () => { + const report1: Report = { + ...LHNTestUtils.getFakeReport(), + type: CONST.REPORT.TYPE.PAYCHECK, + }; + const report2: Report = { + ...LHNTestUtils.getFakeReport(), + type: CONST.REPORT.TYPE.BILL, + }; + const report3: Report = LHNTestUtils.getFakeReport(); + LHNTestUtils.getDefaultRenderedSidebarLinks(report1.reportID); + const reportCollectionDataSet: ReportCollectionDataSet = { + [`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1, + [`${ONYXKEYS.COLLECTION.REPORT}${report2.reportID}`]: report2, + [`${ONYXKEYS.COLLECTION.REPORT}${report3.reportID}`]: report3, + }; + return ( + waitForBatchedUpdates() + .then(() => Onyx.multiSet(reportCollectionDataSet)) + + // Then the reports 1 and 2 are hidden and 3 is not + .then(() => { + const hintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); + const optionRows = screen.queryAllByAccessibilityHint(hintText); + expect(optionRows).toHaveLength(1); + }) + ); + }); + // NOTE: This is also for #focus mode, should we move this test block? describe('all combinations of isArchived, isUserCreatedPolicyRoom, hasAddWorkspaceError, isUnread, isPinned, hasDraft', () => { // Given a report that is the active report and doesn't change @@ -935,33 +964,4 @@ xdescribe('Sidebar', () => { }); }); }); - - describe('filter paycheck and bill report', () => { - const report1: Report = { - ...LHNTestUtils.getFakeReport(), - type: CONST.REPORT.TYPE.PAYCHECK, - }; - const report2: Report = { - ...LHNTestUtils.getFakeReport(), - type: CONST.REPORT.TYPE.BILL, - }; - const report3: Report = LHNTestUtils.getFakeReport(); - LHNTestUtils.getDefaultRenderedSidebarLinks(report1.reportID); - const reportCollectionDataSet: ReportCollectionDataSet = { - [`${ONYXKEYS.COLLECTION.REPORT}${report1.reportID}`]: report1, - [`${ONYXKEYS.COLLECTION.REPORT}${report2.reportID}`]: report2, - [`${ONYXKEYS.COLLECTION.REPORT}${report3.reportID}`]: report3, - }; - return ( - waitForBatchedUpdates() - .then(() => Onyx.multiSet(reportCollectionDataSet)) - - // Then the reports 1 and 2 are hidden and 3 is not - .then(() => { - const hintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); - const optionRows = screen.queryAllByAccessibilityHint(hintText); - expect(optionRows).toHaveLength(1); - }) - ); - }); });