From f9c184536e60a5c9171e812fd0decf02a9eaf6c8 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 18 Jul 2024 23:30:03 +0700 Subject: [PATCH 1/9] hide-paycheck-report-with-error --- src/libs/SidebarUtils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 37b9f3b881d9..e249f904d789 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -105,6 +105,9 @@ function getOrderedReportIDs( if (!report) { return; } + if (report?.type === CONST.REPORT.TYPE.PAYCHECK || report?.type === CONST.REPORT.TYPE.BILL) { + return; + } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); const doesReportHaveViolations = OptionsListUtils.shouldShowViolations(report, betas ?? [], transactionViolations); From d15841dbde246356dd9da5b149039acc37489be9 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 18 Jul 2024 23:49:42 +0700 Subject: [PATCH 2/9] remove white spaces --- src/libs/SidebarUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index e249f904d789..092c064692fd 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -106,7 +106,7 @@ function getOrderedReportIDs( return; } if (report?.type === CONST.REPORT.TYPE.PAYCHECK || report?.type === CONST.REPORT.TYPE.BILL) { - return; + return; } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); From e454d91f236f3293a2ec0301744edd4de7288b50 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 18 Jul 2024 23:52:58 +0700 Subject: [PATCH 3/9] Adding automated test --- tests/unit/SidebarFilterTest.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index 1e0745916717..5a7775d98d8c 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -288,6 +288,13 @@ xdescribe('Sidebar', () => { const report2: Report = { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.BILL, + errorFields: { + "notFound": { + "1721083106781482": "Report not found", + "1721140343800206": "Report not found", + "1721149017870362": "Report not found" + } + }, }; const report3: Report = LHNTestUtils.getFakeReport(); LHNTestUtils.getDefaultRenderedSidebarLinks(report1.reportID); From 953acf15d3e5fe216b4f947b9560337a3cdc5cc0 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 18 Jul 2024 23:55:32 +0700 Subject: [PATCH 4/9] fix styles --- tests/unit/SidebarFilterTest.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index 5a7775d98d8c..e9559dc77efb 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -289,11 +289,11 @@ xdescribe('Sidebar', () => { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.BILL, errorFields: { - "notFound": { - "1721083106781482": "Report not found", - "1721140343800206": "Report not found", - "1721149017870362": "Report not found" - } + notFound: { + '1721083106781482': 'Report not found', + '1721140343800206': 'Report not found', + '1721149017870362': 'Report not found', + }, }, }; const report3: Report = LHNTestUtils.getFakeReport(); From 1a302eac502890419aa5d949aed9b21c37c8602c Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 19 Jul 2024 00:19:28 +0700 Subject: [PATCH 5/9] update type --- src/CONST.ts | 6 ++++-- src/libs/ReportUtils.ts | 2 +- src/libs/SidebarUtils.ts | 2 +- tests/unit/SidebarFilterTest.ts | 10 +++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index dcef6d01f36c..6e548f75f495 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -842,8 +842,10 @@ const CONST = { IOU: 'iou', TASK: 'task', INVOICE: 'invoice', - PAYCHECK: 'paycheck', - BILL: 'bill', + UNSUPPORTED: { + PAYCHECK: 'paycheck', + BILL: 'bill', + }, }, CHAT_TYPE: chatTypes, WORKSPACE_CHAT_ROOMS: { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 5509b8f700b8..9a6d30bd02e8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5468,7 +5468,7 @@ function shouldReportBeInOptionList({ return false; } - if (report?.type === CONST.REPORT.TYPE.PAYCHECK || report?.type === CONST.REPORT.TYPE.BILL) { + if ((Object.values(CONST.REPORT.TYPE.UNSUPPORTED) as string[]).includes(report?.type ?? '')) { return false; } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 092c064692fd..b4928651b6cb 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -105,7 +105,7 @@ function getOrderedReportIDs( if (!report) { return; } - if (report?.type === CONST.REPORT.TYPE.PAYCHECK || report?.type === CONST.REPORT.TYPE.BILL) { + if ((Object.values(CONST.REPORT.TYPE.UNSUPPORTED) as string[]).includes(report?.type ?? '')) { return; } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index e9559dc77efb..f7b69051c674 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -283,16 +283,16 @@ xdescribe('Sidebar', () => { it('filter paycheck and bill report', () => { const report1: Report = { ...LHNTestUtils.getFakeReport(), - type: CONST.REPORT.TYPE.PAYCHECK, + type: CONST.REPORT.TYPE.UNSUPPORTED.PAYCHECK, }; const report2: Report = { ...LHNTestUtils.getFakeReport(), - type: CONST.REPORT.TYPE.BILL, + type: CONST.REPORT.TYPE.UNSUPPORTED.BILL, errorFields: { notFound: { - '1721083106781482': 'Report not found', - '1721140343800206': 'Report not found', - '1721149017870362': 'Report not found', + 1721083106781482: 'Report not found', + 1721140343800206: 'Report not found', + 1721149017870362: 'Report not found', }, }, }; From 2113642e6d4a6d82c5b217563c6bc164955b45e7 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 19 Jul 2024 00:31:12 +0700 Subject: [PATCH 6/9] fix type --- src/libs/ReportUtils.ts | 3 ++- src/libs/SidebarUtils.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9a6d30bd02e8..e5eaab132fd6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5468,7 +5468,8 @@ function shouldReportBeInOptionList({ return false; } - if ((Object.values(CONST.REPORT.TYPE.UNSUPPORTED) as string[]).includes(report?.type ?? '')) { + const unsupportedReportTypes = Object.values(CONST.REPORT.TYPE.UNSUPPORTED) as string[]; + if (unsupportedReportTypes.includes(report?.type ?? '')) { return false; } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index b4928651b6cb..7ce591eff0a3 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -105,7 +105,8 @@ function getOrderedReportIDs( if (!report) { return; } - if ((Object.values(CONST.REPORT.TYPE.UNSUPPORTED) as string[]).includes(report?.type ?? '')) { + const unsupportedReportTypes = Object.values(CONST.REPORT.TYPE.UNSUPPORTED) as string[]; + if (unsupportedReportTypes.includes(report?.type ?? '')) { return; } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; From 632e7ea5df8e53d52d94e1e91e0fefcf9ea9cf2a Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 19 Jul 2024 00:36:47 +0700 Subject: [PATCH 7/9] fix type --- src/CONST.ts | 8 ++++---- src/libs/ReportUtils.ts | 3 +-- src/libs/SidebarUtils.ts | 3 +-- tests/unit/SidebarFilterTest.ts | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 6e548f75f495..8577bf841f0b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -842,10 +842,10 @@ const CONST = { IOU: 'iou', TASK: 'task', INVOICE: 'invoice', - UNSUPPORTED: { - PAYCHECK: 'paycheck', - BILL: 'bill', - }, + }, + UNSUPPORTED: { + PAYCHECK: 'paycheck', + BILL: 'bill', }, CHAT_TYPE: chatTypes, WORKSPACE_CHAT_ROOMS: { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index e5eaab132fd6..c87162e2c74f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5468,8 +5468,7 @@ function shouldReportBeInOptionList({ return false; } - const unsupportedReportTypes = Object.values(CONST.REPORT.TYPE.UNSUPPORTED) as string[]; - if (unsupportedReportTypes.includes(report?.type ?? '')) { + if ((Object.values(CONST.REPORT.UNSUPPORTED) as string[]).includes(report?.type ?? '')) { return false; } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 7ce591eff0a3..4d7c9e7a433e 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -105,8 +105,7 @@ function getOrderedReportIDs( if (!report) { return; } - const unsupportedReportTypes = Object.values(CONST.REPORT.TYPE.UNSUPPORTED) as string[]; - if (unsupportedReportTypes.includes(report?.type ?? '')) { + if ((Object.values(CONST.REPORT.UNSUPPORTED) as string[]).includes(report?.type ?? '')) { return; } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index f7b69051c674..32125ee73b7b 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -283,11 +283,11 @@ xdescribe('Sidebar', () => { it('filter paycheck and bill report', () => { const report1: Report = { ...LHNTestUtils.getFakeReport(), - type: CONST.REPORT.TYPE.UNSUPPORTED.PAYCHECK, + type: CONST.REPORT.UNSUPPORTED.PAYCHECK, }; const report2: Report = { ...LHNTestUtils.getFakeReport(), - type: CONST.REPORT.TYPE.UNSUPPORTED.BILL, + type: CONST.REPORT.UNSUPPORTED.BILL, errorFields: { notFound: { 1721083106781482: 'Report not found', From 7ce466da917e945090f2ada848fcdc989f9aedeb Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 19 Jul 2024 00:44:35 +0700 Subject: [PATCH 8/9] update type --- src/CONST.ts | 2 +- src/libs/ReportUtils.ts | 2 +- src/libs/SidebarUtils.ts | 2 +- tests/unit/SidebarFilterTest.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 8577bf841f0b..201f95ae9f57 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -843,7 +843,7 @@ const CONST = { TASK: 'task', INVOICE: 'invoice', }, - UNSUPPORTED: { + UNSUPPORTED_TYPE: { PAYCHECK: 'paycheck', BILL: 'bill', }, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c87162e2c74f..81a0125be15a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5468,7 +5468,7 @@ function shouldReportBeInOptionList({ return false; } - if ((Object.values(CONST.REPORT.UNSUPPORTED) as string[]).includes(report?.type ?? '')) { + if ((Object.values(CONST.REPORT.UNSUPPORTED_TYPE) as string[]).includes(report?.type ?? '')) { return false; } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 4d7c9e7a433e..2d609b7279a4 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -105,7 +105,7 @@ function getOrderedReportIDs( if (!report) { return; } - if ((Object.values(CONST.REPORT.UNSUPPORTED) as string[]).includes(report?.type ?? '')) { + if ((Object.values(CONST.REPORT.UNSUPPORTED_TYPE) as string[]).includes(report?.type ?? '')) { return; } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index 32125ee73b7b..1aa44fef2f84 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -283,11 +283,11 @@ xdescribe('Sidebar', () => { it('filter paycheck and bill report', () => { const report1: Report = { ...LHNTestUtils.getFakeReport(), - type: CONST.REPORT.UNSUPPORTED.PAYCHECK, + type: CONST.REPORT.UNSUPPORTED_TYPE.PAYCHECK, }; const report2: Report = { ...LHNTestUtils.getFakeReport(), - type: CONST.REPORT.UNSUPPORTED.BILL, + type: CONST.REPORT.UNSUPPORTED_TYPE.BILL, errorFields: { notFound: { 1721083106781482: 'Report not found', From 886e6cfcae9514477ba15b84a186549e7968df1a Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 19 Jul 2024 00:57:47 +0700 Subject: [PATCH 9/9] fix type --- tests/unit/SidebarFilterTest.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index 1aa44fef2f84..1c70993c8fad 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -290,9 +290,7 @@ xdescribe('Sidebar', () => { type: CONST.REPORT.UNSUPPORTED_TYPE.BILL, errorFields: { notFound: { - 1721083106781482: 'Report not found', - 1721140343800206: 'Report not found', - 1721149017870362: 'Report not found', + error: 'Report not found', }, }, };