diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index 095864ad2fff..4636778cc199 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -142,10 +142,7 @@ function getOrderedReportIDs(reportIDFromRoute) { pinnedReportOptions.push(report); } else if (report.hasOutstandingIOU && !report.isIOUReportOwner) { iouDebtReportOptions.push(report); - - // If the active report has a draft, we do not put it in the group of draft reports because we want it to maintain it's current position. Otherwise the report's position - // jumps around in the LHN and it's kind of confusing to the user to see the LHN reorder when they start typing a comment on a report. - } else if (report.hasDraft && report.reportID !== reportIDFromRoute) { + } else if (report.hasDraft) { draftReportOptions.push(report); } else { recentReportOptions.push(report); diff --git a/tests/unit/LHNOrderTest.js b/tests/unit/LHNOrderTest.js index 557ff828a36b..466ebd425d60 100644 --- a/tests/unit/LHNOrderTest.js +++ b/tests/unit/LHNOrderTest.js @@ -124,7 +124,7 @@ describe('Sidebar', () => { }); }); - it('doesn\'t change the order when adding a draft to the active report', () => { + it('changes the order when adding a draft to the active report', () => { // Given three reports in the recently updated order of 3, 2, 1 // And the first report has a draft // And the currently viewed report is the first report @@ -147,7 +147,7 @@ describe('Sidebar', () => { [`${ONYXKEYS.COLLECTION.REPORT}${report3.reportID}`]: report3, })) - // Then there should be a pencil icon and report one should still be the last one because putting a draft on the active report should not change it's location + // Then there should be a pencil icon and report one should be the first one because putting a draft on the active report should change its location // in the ordered list .then(() => { const pencilIcon = sidebarLinks.getAllByAccessibilityHint('Pencil Icon'); @@ -155,9 +155,9 @@ describe('Sidebar', () => { const displayNames = sidebarLinks.queryAllByA11yLabel('Chat user display names'); expect(displayNames).toHaveLength(3); - expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('Five, Six'); - expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Three, Four'); - expect(lodashGet(displayNames, [2, 'props', 'children'])).toBe('One, Two'); + expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('One, Two'); // this has `hasDraft` flag enabled so it will be on top + expect(lodashGet(displayNames, [1, 'props', 'children'])).toBe('Five, Six'); + expect(lodashGet(displayNames, [2, 'props', 'children'])).toBe('Three, Four'); }); });