diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 4f227e04482a..80081c8f89c7 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -126,21 +126,22 @@ function getOrderedReportIDs( } }); - // The LHN is split into four distinct groups, and each group is sorted a little differently. The groups will ALWAYS be in this order: + // The LHN is split into five distinct groups, and each group is sorted a little differently. The groups will ALWAYS be in this order: // 1. Pinned/GBR - Always sorted by reportDisplayName - // 2. Drafts - Always sorted by reportDisplayName - // 3. Non-archived reports and settled IOUs + // 2. Error reports - Always sorted by reportDisplayName + // 3. Drafts - Always sorted by reportDisplayName + // 4. Non-archived reports and settled IOUs // - Sorted by lastVisibleActionCreated in default (most recent) view mode // - Sorted by reportDisplayName in GSD (focus) view mode - // 4. Archived reports + // 5. Archived reports // - Sorted by lastVisibleActionCreated in default (most recent) view mode // - Sorted by reportDisplayName in GSD (focus) view mode const pinnedAndGBRReports: MiniReport[] = []; + const errorReports: MiniReport[] = []; const draftReports: MiniReport[] = []; const nonArchivedReports: MiniReport[] = []; const archivedReports: MiniReport[] = []; - const errorReports: MiniReport[] = []; if (currentPolicyID || policyMemberAccountIDs.length > 0) { reportsToDisplay = reportsToDisplay.filter( @@ -160,12 +161,12 @@ function getOrderedReportIDs( const reportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report, reportAction)) { pinnedAndGBRReports.push(miniReport); + } else if (report?.hasErrorsOtherThanFailedReceipt) { + errorReports.push(miniReport); } else if (hasValidDraftComment(report?.reportID ?? '-1')) { draftReports.push(miniReport); } else if (ReportUtils.isArchivedRoom(report)) { archivedReports.push(miniReport); - } else if (report?.hasErrorsOtherThanFailedReceipt) { - errorReports.push(miniReport); } else { nonArchivedReports.push(miniReport); }