diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 571b5ec68f4a..18180f2be762 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7339,6 +7339,16 @@ function reasonForReportToBeInOptionList({ return null; } + const currentReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`] ?? {}; + const reportActionValues = Object.values(currentReportActions); + const hasOnlyCreatedAction = reportActionValues.length === 1 && reportActionValues.at(0)?.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED; + + // Hide empty reports that have only a `CREATED` action, a total of 0, and are in a submitted state + // These reports should be hidden because they appear empty to users and there is nothing actionable for them to do + if (report?.total === 0 && report?.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && report?.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED && hasOnlyCreatedAction) { + return null; + } + // We used to use the system DM for A/B testing onboarding tasks, but now only create them in the Concierge chat. We // still need to allow existing users who have tasks in the system DM to see them, but otherwise we don't need to // show that chat diff --git a/tests/ui/LHNItemsPresence.tsx b/tests/ui/LHNItemsPresence.tsx index 478283b59e35..a69c5f7de6bd 100644 --- a/tests/ui/LHNItemsPresence.tsx +++ b/tests/ui/LHNItemsPresence.tsx @@ -528,5 +528,40 @@ describe('SidebarLinksData', () => { // Then the report should not disappear in the sidebar because it's read expect(getOptionRows()).toHaveLength(0); }); + + it('should not display an empty submitted report having only a CREATED action', async () => { + // Given the SidebarLinks are rendered + LHNTestUtils.getDefaultRenderedSidebarLinks(); + + // When creating a report with total = 0, stateNum = SUBMITTED, statusNum = SUBMITTED + const report = { + ...createReport(false, [1, 2], 0), + total: 0, + stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, + statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, + }; + + // And setting up a report action collection with only a CREATED action + const reportActionID = '1'; + const reportAction = { + ...LHNTestUtils.getFakeReportAction(), + reportActionID, + actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, + }; + + // When the Onyx state is initialized with this report + await initializeState({ + [`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report, + }); + + // And a report action collection with only a CREATED action is added + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, { + [reportActionID]: reportAction, + }); + + // Then the report should not be displayed in the sidebar + expect(getOptionRows()).toHaveLength(0); + expect(getDisplayNames()).toHaveLength(0); + }); }); });