Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to hide an open report, even if it's empty. This caused a regression here: #67407 (comment)

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
Expand Down
35 changes: 35 additions & 0 deletions tests/ui/LHNItemsPresence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});