Skip to content

Agents - App returns to LHN after creating agent and tapping back button on agent chat #97832

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.50-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #95631
Email or phone of affected tester (no customers): koinjojoinjionjioiojoinjoi@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: User Settings

Action Performed:

  1. Launch Expensify app.
  2. Go to Account > Agents.
  3. Tap New agent.
  4. Create a new agent.
  5. Tap app back button.

Expected Result:

App will return to Agents after tapping back button on agent chat.

Actual Result:

App returns to LHN after creating agent and tapping back button on agent chat.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7225969_1785881117704.2.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7225969

Activity

  1. applause-bot commented on Aug 4, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/36c9384525e5f078af880427f578c3101686bb530344638bac887af747872803

  2. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 4, 2026
  3. melvin-bot commented on Aug 4, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #95631

  4. melvin-bot commented on Aug 4, 2026

    @melvin-bot

    @chuckdries @eVoloshchak you have been assigned to this deploy blocker because you reviewed the offending PR: #95631

  5. melvin-bot commented on Aug 4, 2026

    @melvin-bot

    @mjasikowski you have been assigned to this deploy blocker because you authored the offending PR: #95631

  6. melvin-bot commented on Aug 4, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  7. github-actions commented on Aug 4, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  8. MelvinBot commented on Aug 4, 2026

    @MelvinBot
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #95631 - "Open the agent DM via an optimistic reportID" by @mjasikowski (High confidence)
    Related Issues: #94395 (the feature this PR implements)

    Recommendation: ROLL FORWARD

    This is a brand-new feature (immediate agent DM after creation) that ships with already-deployed backend dependencies (Auth#22772, Web-Expensify#54367), and the regression is a contained navigation-stack issue on narrow layouts — a targeted fix is safer and smaller than reverting the whole feature. Reverting is a viable fallback if a quick fix isn't ready, since it cleanly restores the old dismissModal() flow that returned to the Agents list.

    Assigned: @mjasikowski (PR author), @eVoloshchak (approving reviewer), @chuckdries (approving reviewer) — already auto-assigned as author/reviewers of the causing PR.
    Labels: No changes. DeployBlockerCash is correctly applied (App deploy is blocked by a frontend regression) and is kept. No DeployBlocker (Web) label is present.

    📋 Detailed Analysis

    Evidence

    • The bug is reproducible only on staging (v9.4.50-0) and is N/A on production because the "open agent DM immediately after creation" behavior is brand new — introduced by PR Open the agent DM via an optimistic reportID #95631, which merged 2026-08-04T15:27:29Z, hours before this blocker was filed.
    • The reported flow (create agent → tap back on the agent chat → land on LHN instead of the Agents list) is exactly the navigation path this PR rewrote. It is reported on Android: App and iOS: App (native = narrow layout), which is precisely the branch the PR changed.
    • The PR is listed in the current StagingDeployCash deploy checklist (Deploy Checklist: New Expensify 2026-08-04 #97828).

    Verification

    • Affected file/flow: src/pages/settings/Agents/AddAgentPage.tsx → handleSubmit, and the navigation helper src/libs/Navigation/Navigation.ts → revealRouteBeforeDismissingModal.
    • Before this PR, handleSubmit ended with Navigation.dismissModal(), which popped the RHP modal stack back to the Agents list.
    • PR Open the agent DM via an optimistic reportID #95631 replaced that with a layout-branched navigation. Confirmed via gh pr diff 95631 and the current checked-out source.

    Root Cause

    On narrow (native) layouts, handleSubmit now runs:

    if (getIsNarrowLayout()) {
    // Reveal the DM under the modal before dismissing so we navigate directly to it in one animation,
    // instead of dismissing to the agents list first and navigating to the DM afterward.
    Navigation.revealRouteBeforeDismissingModal(ROUTES.REPORT_WITH_ID.getRoute(optimisticReportID));
    return;
    }

    revealRouteBeforeDismissingModal(ROUTES.REPORT_WITH_ID.getRoute(optimisticReportID)) inserts the DM as a fullscreen route under the RHP and then dismisses the entire RHP modal stack:

    function revealRouteBeforeDismissingModal(route: Route, options?: {afterTransition?: () => void}) {
    if (!canNavigate('revealRouteBeforeDismissingModal', {route}) || !navigationRef.current) {
    Log.hmmm(`[Navigation] Unable to reveal route before dismissing modal. Can't navigate.`, {route});
    return;
    }
    requestAnimationFrame(() => {
    navigationRef.current?.dispatch({
    type: CONST.NAVIGATION.ACTION_TYPE.REPLACE_FULLSCREEN_UNDER_RHP,
    payload: {route},
    });
    // Nested rAF: the first frame commits the route insertion, the second
    // frame starts the dismiss. This ensures React processes the two dispatches
    // in separate renders so the dismiss animation is preserved. On narrow,
    // wait for the hidden destination transition first so the RHP slides out
    // over the final page instead of briefly revealing the previous page.
    requestAnimationFrame(() => {
    dismissModal({afterTransition: options?.afterTransition, waitForTransition: getIsNarrowLayout()});
    });
    });
    }

    Because the whole Settings → Agents → New agent modal stack is dismissed and the DM is opened as a top-level fullscreen report split, the Agents list is no longer anywhere in the back stack. Tapping the back button on the agent chat therefore falls through to the LHN (report list) rather than returning to the Agents list.

    By contrast, the wide-layout branch keeps the DM inside the RHP:

    // On wide layouts, open the DM in a dedicated RHP screen instead of the fullscreen report split.
    // forceReplace swaps this screen out for the DM instead of pushing on top of it, so the
    // already-submitted form can't be reached again via the close/back button.
    Navigation.navigate(ROUTES.AGENT_REPORT.getRoute(optimisticReportID), {forceReplace: true});

    so the discrepancy is confined to the narrow-layout revealRouteBeforeDismissingModal path.

    Targeted fix direction: on narrow layouts, navigate to the new DM in a way that preserves the Agents settings screen in the back stack (e.g. push/replace the report onto the existing settings modal stack instead of revealing it under the modal and dismissing the whole stack), so back returns to the Agents list as expected.

  9. 45 remaining items

  10. eVoloshchak commented on Sep 14, 2026

    @eVoloshchak
    Contributor

    Not overdue

  11. mjasikowski commented on Sep 17, 2026

    @mjasikowski
    Contributor

    Back from leave and on it

  12. added and removed
    Awaiting PaymentAuto-added when associated PR is deployed to production
    on Sep 18, 2026
  13. mjasikowski commented on Sep 18, 2026

    @mjasikowski
    Contributor

    Just tested again and this is fixed

  14. chuckdries commented on Sep 29, 2026

    @chuckdries
    Contributor

    @mjasikowski can we close it then?

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions