Skip to content

Commit

Permalink
Merge pull request #46167 from daledah/fix/46085
Browse files Browse the repository at this point in the history
fix: leaving from multilevel threads navigates to wrong thread
  • Loading branch information
marcaaron authored Jul 31, 2024
2 parents 4c0917d + 947c16c commit d2ac23b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1232,9 +1232,10 @@ function hasExpensifyGuidesEmails(accountIDs: number[]): boolean {
}

function getMostRecentlyVisitedReport(reports: Array<OnyxEntry<Report>>, reportMetadata: OnyxCollection<ReportMetadata>): OnyxEntry<Report> {
const filteredReports = reports.filter(
(report) => !!report?.reportID && !!(reportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`]?.lastVisitTime ?? report?.lastReadTime),
);
const filteredReports = reports.filter((report) => {
const shouldKeep = !isChatThread(report) || report?.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
return shouldKeep && !!report?.reportID && !!(reportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`]?.lastVisitTime ?? report?.lastReadTime);
});
return lodashMaxBy(filteredReports, (a) => new Date(reportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${a?.reportID}`]?.lastVisitTime ?? a?.lastReadTime ?? '').valueOf());
}

Expand Down

0 comments on commit d2ac23b

Please sign in to comment.