Skip to content

Commit

Permalink
Merge pull request #46950 from bernhardoj/fix/45474-delete-task-show-…
Browse files Browse the repository at this point in the history
…not-found

Navigate back to the most recent report if parent report doesn't exist when deleting task
  • Loading branch information
MonilBhavsar authored Aug 12, 2024
2 parents 88ad9c7 + d2b8777 commit cc2efc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2674,6 +2674,11 @@ function navigateToMostRecentReport(currentReport: OnyxEntry<Report>) {
}
}

function getMostRecentReportID(currentReport: OnyxEntry<Report>) {
const lastAccessedReportID = ReportUtils.findLastAccessedReport(false, false, undefined, currentReport?.reportID)?.reportID;
return lastAccessedReportID ?? conciergeChatReportID;
}

function joinRoom(report: OnyxEntry<Report>) {
if (!report) {
return;
Expand Down Expand Up @@ -4031,6 +4036,7 @@ export {
showReportActionNotification,
toggleEmojiReaction,
shouldShowReportActionNotification,
getMostRecentReportID,
joinRoom,
leaveRoom,
inviteToRoom,
Expand Down
8 changes: 7 additions & 1 deletion src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,13 @@ function deleteTask(report: OnyxEntry<OnyxTypes.Report>) {
Report.notifyNewAction(report.reportID, currentUserAccountID);

if (shouldDeleteTaskReport) {
return ROUTES.REPORT_WITH_ID.getRoute(parentReport?.reportID ?? '-1');
if (parentReport?.reportID) {
return ROUTES.REPORT_WITH_ID.getRoute(parentReport.reportID);
}
const mostRecentReportID = Report.getMostRecentReportID(report);
if (mostRecentReportID) {
return ROUTES.REPORT_WITH_ID.getRoute(mostRecentReportID);
}
}
}

Expand Down

0 comments on commit cc2efc6

Please sign in to comment.