Skip to content

Commit

Permalink
Merge pull request #45698 from cretadn22/hide-paycheck-report
Browse files Browse the repository at this point in the history
Fix: Hide paycheck report with error
  • Loading branch information
puneetlath authored Jul 18, 2024
2 parents 96353f9 + 886e6cf commit eb6ca6d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,8 @@ const CONST = {
IOU: 'iou',
TASK: 'task',
INVOICE: 'invoice',
},
UNSUPPORTED_TYPE: {
PAYCHECK: 'paycheck',
BILL: 'bill',
},
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.UNSUPPORTED_TYPE) as string[]).includes(report?.type ?? '')) {
return false;
}

Expand Down
3 changes: 3 additions & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ function getOrderedReportIDs(
if (!report) {
return;
}
if ((Object.values(CONST.REPORT.UNSUPPORTED_TYPE) as string[]).includes(report?.type ?? '')) {
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);
Expand Down
9 changes: 7 additions & 2 deletions tests/unit/SidebarFilterTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,16 @@ xdescribe('Sidebar', () => {
it('filter paycheck and bill report', () => {
const report1: Report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.PAYCHECK,
type: CONST.REPORT.UNSUPPORTED_TYPE.PAYCHECK,
};
const report2: Report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.BILL,
type: CONST.REPORT.UNSUPPORTED_TYPE.BILL,
errorFields: {
notFound: {
error: 'Report not found',
},
},
};
const report3: Report = LHNTestUtils.getFakeReport();
LHNTestUtils.getDefaultRenderedSidebarLinks(report1.reportID);
Expand Down

0 comments on commit eb6ca6d

Please sign in to comment.