Skip to content

Task Report - App remains on deleted task instead of redirecting to parent chat #80725

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.10-3
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #77948
Email or phone of affected tester (no customers): applausetester+ap3@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 11
App Component: Other

Action Performed:

1.Open a group chat
2.Open a task report
3.Click the report header
4.Select Details
5.Click Delete
6.Confirm deletion

Expected Result:

User is redirected back to the parent group chat after deleting the task report.

Actual Result:

User remains on the deleted task report screen after confirming deletion. The task no longer exists but the UI stays on the task view, leaving the user in an invalid report context. Other delete flows redirect correctly, making this behavior inconsistent.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 28, 2026
  2. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 28, 2026
  3. melvin-bot commented on Jan 28, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @linhvovan29546 (External)

  4. melvin-bot commented on Jan 28, 2026

    @melvin-bot

    Triggered auto assignment to @lydiabarclay (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. daledah commented on Jan 28, 2026

    @daledah
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user deletes a task report from the Details page (Group chat > Task > Header > Details > Delete), they remain on the deleted task report screen instead of being redirected back to the parent group chat. The task no longer exists but the UI stays on the task view, leaving the user in an invalid report context.

    What is the root cause of that problem?

    The root cause is that the navigateToTargetUrl function in ReportDetailsPage.tsx does not handle navigation for task report deletions.

    Looking at the navigation logic in ReportDetailsPage.tsx:

    // Where to navigate back to after deleting the transaction and its report.
    const navigateToTargetUrl = useCallback(() => {
    let urlToNavigateBack: string | undefined;
    // Only proceed with navigation logic if transaction was actually deleted
    if (!isEmptyObject(requestParentReportAction)) {
    const rootState = navigationRef.getRootState();
    const rhp = rootState.routes.at(-1);
    const rhpRoutes = rhp?.state?.routes ?? [];
    const previousRoute = rhpRoutes.at(-2);
    const superWideRHPIndex = rhpRoutes.findIndex((rhpRoute) => SUPER_WIDE_RIGHT_MODALS.has(rhpRoute.name));
    // If the deleted expense is displayed directly below, close the entire RHP
    const isSuperWideRHPDisplayed = superWideRHPIndex > -1;
    const isSuperWideRHPDisplayedDirectlyBelow = isSuperWideRHPDisplayed && superWideRHPIndex === rhpRoutes.length - 2;
    if (
    isSuperWideRHPDisplayedDirectlyBelow &&
    (previousRoute?.params as RightModalNavigatorParamList[typeof SCREENS.RIGHT_MODAL.SEARCH_MONEY_REQUEST_REPORT])?.reportID === route.params.reportID
    ) {
    Navigation.dismissModal();
    return;
    }
    // If the deleted expense is opened from the super wide rhp, go back there.
    if (
    previousRoute?.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT &&
    (previousRoute.params as RightModalNavigatorParamList[typeof SCREENS.RIGHT_MODAL.SEARCH_REPORT])?.reportID === route.params.reportID
    ) {
    if (isSuperWideRHPDisplayed) {
    const distanceToPop = rhpRoutes.length - 1 - superWideRHPIndex;
    navigationRef.dispatch({...StackActions.pop(distanceToPop), target: rhp?.state?.key});
    return;
    }
    Navigation.dismissModal();
    return;
    }
    const isTrackExpense = isTrackExpenseAction(requestParentReportAction);
    if (isTrackExpense) {
    urlToNavigateBack = getNavigationUrlAfterTrackExpenseDelete(
    moneyRequestReport?.reportID,
    moneyRequestReport,
    iouTransactionID,
    requestParentReportAction,
    iouReport,
    chatIOUReport,
    isChatIOUReportArchived,
    isSingleTransactionView,
    );
    } else {
    urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete(
    iouTransactionID,
    requestParentReportAction,
    iouReport,
    chatIOUReport,
    isChatIOUReportArchived,
    isSingleTransactionView,
    );
    }
    }
    if (!urlToNavigateBack) {
    Navigation.dismissModal();
    } else {
    setDeleteTransactionNavigateBackUrl(urlToNavigateBack);
    navigateBackOnDeleteTransaction(urlToNavigateBack as Route);
    }
    }, [requestParentReportAction, route.params.reportID, moneyRequestReport, iouTransactionID, iouReport, chatIOUReport, isChatIOUReportArchived, isSingleTransactionView]);

    The navigateToTargetUrl function only handles navigation for expense/money request deletions when requestParentReportAction is not empty:

    For task reports (caseID === CASES.DEFAULT), requestParentReportAction is not relevant to tasks, so the condition fails and urlToNavigateBack remains undefined. This results in Navigation.dismissModal() being called, which doesn't properly navigate back to the parent report.

    Additionally, while deleteTask in Task.ts does compute the correct URL using getNavigationUrlOnTaskDelete:

    App/src/libs/actions/Task.ts

    Lines 1186 to 1190 in 04bfa3e

    const urlToNavigateBack = getNavigationUrlOnTaskDelete(report);
    if (urlToNavigateBack) {
    Navigation.goBack();
    return urlToNavigateBack;
    }

    It only calls Navigation.goBack() which goes back in the navigation stack, not to the specific parent report. If the user navigated to the task Details page (Task > Header > Details), goBack() would return to the task report, not the parent group chat.

    What changes do you think we should make in order to solve the problem?

    Update the navigateToTargetUrl function in ReportDetailsPage.tsx to handle task report deletions by using getNavigationUrlOnTaskDelete:

    +import {getNavigationUrlOnTaskDelete} from '@userActions/Task';
    +
     const navigateToTargetUrl = useCallback(() => {
         let urlToNavigateBack: string | undefined;
    +    
    +    // Handle task deletion navigation
    +    if (caseID === CASES.DEFAULT) {
    +        urlToNavigateBack = getNavigationUrlOnTaskDelete(report);
    +        if (urlToNavigateBack) {
    +            navigateBackOnDeleteTransaction(urlToNavigateBack as Route);
    +            return;
    +        }
    +        Navigation.dismissModal();
    +        return;
    +    }
    +
         // Only proceed with navigation logic if transaction was actually deleted
         if (!isEmptyObject(requestParentReportAction)) {
             // ... existing expense navigation logic ...
         }
         // ... rest of function
    -}, [requestParentReportAction, route.params.reportID, moneyRequestReport, iouTransactionID, iouReport, chatIOUReport, isChatIOUReportArchived, isSingleTransactionView]);
    +}, [caseID, report, requestParentReportAction, route.params.reportID, moneyRequestReport, iouTransactionID, iouReport, chatIOUReport, isChatIOUReportArchived, isSingleTransactionView]);

    Additionally, the navigation logic in deleteTask function can be simplified since navigation is now handled by navigateToTargetUrl:

    -    const urlToNavigateBack = getNavigationUrlOnTaskDelete(report);
    -    if (urlToNavigateBack) {
    -        Navigation.goBack();
    -        return urlToNavigateBack;
    -    }
    +    // Navigation is handled by the caller (ReportDetailsPage)

    What alternative solutions did you explore? (Optional)

    An alternative would be to fix the navigation in deleteTask function itself by replacing Navigation.goBack() with a proper navigation to the parent report:

    const urlToNavigateBack = getNavigationUrlOnTaskDelete(report);
    if (urlToNavigateBack) {
        navigateBackOnDeleteTransaction(urlToNavigateBack as Route);
    }
  6. yatin-italy commented on Jan 28, 2026

    @yatin-italy

    🚨 Edited by proposal-police: This proposal was edited at 2026-01-28 10:30:35 UTC.

    Proposal

    Restate the problem this issue is trying to solve.

    When a task report is deleted from the Details page, the task is removed but the app stays on the deleted task screen. The UI does not move back to the parent group chat. This leaves the user on an invalid report. Other delete flows already redirect correctly, so this behavior is inconsistent.

    What is the root cause of that problem?

    The root cause is a wrong assumption in navigateToTargetUrl() inside src/pages/ReportDetailsPage.tsx. The function assumes that deletion navigation is only needed for money requests and checks only requestParentReportAction. For tasks, this value is empty, so the function does not compute a navigation URL and dismisses the modal. This happens before deleteTask() runs, so task deletion navigation never occurs.

    What changes do you think we should make in order to solve the problem?

    • Move all task deletion navigation out of the action layer and into the component layer, same as money requests.
    • Handle task deletion inside navigateToTargetUrl() using the existing helper.

    File: src/libs/actions/Task.ts
    Remove navigation from deleteTask() so it does not try to navigate after deletion.

    API.write(WRITE_COMMANDS.CANCEL_TASK, parameters, {optimisticData, successData, failureData});
    notifyNewAction(report.reportID, currentUserAccountID);
    // Navigation is handled by the caller (ReportDetailsPage or HeaderView)

    File: src/pages/ReportDetailsPage.tsx
    Add task handling to navigateToTargetUrl().

    Add import:

    import {canActionTask, canModifyTask, deleteTask, getNavigationUrlOnTaskDelete, reopenTask} from '@userActions/Task';

    Update callback:

    const navigateToTargetUrl = useCallback(() => {
        let urlToNavigateBack: string | undefined;
    
        // Handle task deletion
        if (caseID === CASES.DEFAULT) {
            urlToNavigateBack = getNavigationUrlOnTaskDelete(report);
            if (urlToNavigateBack) {
                setDeleteTransactionNavigateBackUrl(urlToNavigateBack);
                navigateBackOnDeleteTransaction(urlToNavigateBack as Route, true);
                return;
            }
            Navigation.dismissModal();
            return;
        }
    
        if (!isEmptyObject(requestParentReportAction)) {
            const isTrackExpense = isTrackExpenseAction(requestParentReportAction);
            if (isTrackExpense) {
                urlToNavigateBack = getNavigationUrlAfterTrackExpenseDelete(
                    moneyRequestReport?.reportID,
                    moneyRequestReport,
                    iouTransactionID,
                    requestParentReportAction,
                    iouReport,
                    chatIOUReport,
                    isChatIOUReportArchived,
                    isSingleTransactionView,
                );
            } else {
                urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete(
                    iouTransactionID,
                    requestParentReportAction,
                    iouReport,
                    chatIOUReport,
                    isChatIOUReportArchived,
                    isSingleTransactionView,
                );
            }
        }
    
        if (!urlToNavigateBack) {
            Navigation.dismissModal();
        } else {
            setDeleteTransactionNavigateBackUrl(urlToNavigateBack);
            navigateBackOnDeleteTransaction(urlToNavigateBack as Route, true);
        }
    }, [caseID, report, iouTransactionID, requestParentReportAction, isSingleTransactionView, moneyRequestReport, isChatIOUReportArchived, iouReport, chatIOUReport]);

    File: src/pages/home/HeaderView.tsx
    Handle navigation when deletion starts from the header.

    Add imports:

    import {navigateBackOnDeleteTransaction} from '@libs/ReportUtils';
    import {deleteTask, getNavigationUrlOnTaskDelete} from '@userActions/Task';

    Update confirm handler:

    <ConfirmModal
        isVisible={isDeleteTaskConfirmModalVisible}
        onConfirm={() => {
            setIsDeleteTaskConfirmModalVisible(false);
            deleteTask(
                report,
                parentReport,
                isReportArchived,
                currentUserPersonalDetails.accountID,
                hasOutstandingChildTask,
                parentReportAction ?? undefined,
                ancestors,
            );
    
            const urlToNavigateBack = getNavigationUrlOnTaskDelete(report);
            if (urlToNavigateBack) {
                navigateBackOnDeleteTransaction(urlToNavigateBack as Route);
            }
        }}
        onCancel={() => setIsDeleteTaskConfirmModalVisible(false)}
        title={translate('task.deleteTask')}
        prompt={translate('task.deleteConfirmation')}
        confirmText={translate('common.delete')}
        cancelText={translate('common.cancel')}
        danger
        shouldEnableNewFocusManagement
    />

    What alternative solutions did you explore? (Optional)

    • Keep navigation inside deleteTask(). This was not chosen because component cleanup already runs first, so navigation there is too late and unreliable.
  7. marufsharifi commented on Jan 28, 2026

    @marufsharifi
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user deletes a task report from the Report Details screen, the app closes the right-hand panel but lands on the deleted task report instead of redirecting back to the parent group chat.

    What is the root cause of that problem?

    The delete task flow does figure out the right place to go (the parent chat), but it never actually uses that route. In src/libs/actions/Task.ts,

    App/src/libs/actions/Task.ts

    Lines 1188 to 1192 in dc827a9

    Navigation.goBack();
    return urlToNavigateBack;
    }
    }

    the computed back route is returned, yet the function previously only performed a simple Navigation.goBack().
    Instead, it just does a simple “go back one screen.” That closes the panel, but the next screen is still the deleted task report. On the caller side, src/pages/ReportDetailsPage.tsx:

    const deleteTransaction = useCallback(() => {
    if (caseID === CASES.DEFAULT) {
    deleteTask(report, parentReport, isReportArchived, currentUserPersonalDetails.accountID, hasOutstandingChildTask, parentReportAction, ancestors);
    return;
    }

    doesn’t apply the standard “dismiss RHP + go back to parent chat” helper.

    What changes do you think we should make in order to solve the problem?

    return the computed back route from task deletion without doing internal navigation, and then use navigateBackOnDeleteTransaction from ReportDetailsPage to dismiss the RHP and navigate to the parent chat.

    We should remove the Navigation.goBack() in src/libs/actions/Task.ts

         const urlToNavigateBack = getNavigationUrlOnTaskDelete(report);
        if (urlToNavigateBack) {
    -        Navigation.goBack();
           return urlToNavigateBack;
       }
    

    and in src/pages/ReportDetailsPage.tsx

    -        if (caseID === CASES.DEFAULT) {
    -            deleteTask(report, parentReport, isReportArchived, currentUserPersonalDetails.accountID, hasOutstandingChildTask, parentReportAction, ancestors);
    -            return;
    -        }
    +        if (caseID === CASES.DEFAULT) {
    +            const urlToNavigateBack = deleteTask(
    +                report,
    +                parentReport,
    +                isReportArchived,
    +                currentUserPersonalDetails.accountID,
    +                hasOutstandingChildTask,
    +                parentReportAction,
    +                ancestors,
    +            );
    +            navigateBackOnDeleteTransaction(urlToNavigateBack as Route);
    +            return;
    +        }

    What alternative solutions did you explore? (Optional)

  8. github-actions commented on Jan 28, 2026

    @github-actions
    Contributor

    ⚠️ @marufsharifi Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  9. 39 remaining items

  10. mallenexpensify commented on May 26, 2026

    @mallenexpensify
    Contributor

    Retest requested

  11. m-natarajan commented on May 27, 2026

    @m-natarajan

    Not repro, Windows 11 / Chrome, v9.3.83-0

    27.05.2026_10.11.56_REC.mp4
  12. mallenexpensify commented on May 27, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @linhvovan29546 paid $250 via Upwork
    Contributor+: @daledah due $250 via NewDot

    @linhvovan29546 can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022059672194106395024

  13. melvin-bot commented on May 27, 2026

    @melvin-bot

    Current assignee @mallenexpensify is eligible for the Awaiting Payment assigner, not assigning anyone new.

  14. linhvovan29546 commented on May 27, 2026

    @linhvovan29546
    Contributor

    @mallenexpensify I've accepted the offer

  15. mallenexpensify commented on May 29, 2026

    @mallenexpensify
    Contributor

    @linhvovan29546 paid, summary updated above. Thx.

  16. quinthar commented on May 30, 2026

    @quinthar
    Contributor

    Approved $250 to @daledah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions