Skip to content

Agents - Not here page opens after switching to agent, avatar shows fallback avatar #89852

Closed

Description

@mitarachim

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.68-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: #89547
Email or phone of affected tester (no customers): applausetester+sjdiosn2ddd2d@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Other

Action Performed:

Precondition:

  • Log in with Expensifail account.
  1. Go to staging.new.expensify.com
  2. Go to Account > Agents.
  3. Click New agent > Save.
  4. Open account switcher.
  5. Select the agent.

Expected Result:

Not here page will not open after switching to agent.
Avatar will load.

Actual Result:

Not here page opens after switching to agent.
Avatar shows fallback avatar.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7146613_1778110596826.09.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCash
    Daily
    Bug
    DeployBlocker
    on May 7, 2026
  2. melvin-bot commented on May 7, 2026

    @melvin-bot

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

  3. melvin-bot commented on May 7, 2026

    @melvin-bot

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

  4. github-actions commented on May 7, 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.
  5. OSBotify commented on May 7, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #89547 - "feat: [89310] add agents flow" by @NicolasBonet (High confidence)
    Related Issues: #89310

    Recommendation: REVERT

    PR #89547 introduced the agent creation flow, but the account switching behavior after creating an agent leads to the "Not here" page and fallback avatar. This is a staging-only issue (new feature, not in production), and the fix requires changes to the App repo.

    Assigned: @NicolasBonet (PR author), @puneetlath (approving reviewer) from highest-confidence causing PR only
    Labels: Removed DeployBlocker (backend label) — this is a frontend bug. DeployBlockerCash retained.

    Evidence and Detailed Analysis

    Evidence

    • The melvin-bot comment on the issue explicitly points to #89547 as the responsible PR
    • PR feat: [89310] add agents flow #89547 is present in the current StagingDeployCash checklist (entry Make enter key submit form #47 in merge order)
    • The issue title and repro steps describe a flow introduced by this PR (Account > Agents > New agent > Save > switch to agent)
    • The bug is staging-only: "Reproducible in production?: N/A - new feature, doesn't exist in prod"

    Verification

    • Affected files: src/libs/actions/Agent.ts, src/pages/settings/Agents/AgentsPage.tsx, src/pages/settings/Agents/AddAgentPage.tsx
    • PR feat: [89310] add agents flow #89547 adds all of these files and the agent creation API call (WRITE_COMMANDS.CREATE_AGENT)
    • The createAgent function writes an optimistic PERSONAL_DETAILS_LIST entry with a negative optimisticAccountID, then clears it on success — leaving the real agent account details dependent on the server response
    • AgentsPage.tsx renders NotFoundPage when !isCustomAgentEnabled (line 96), meaning if the agent's session doesn't carry the CUSTOM_AGENT beta permission, the "Not here" page is shown immediately upon switching to the agent
    • The fallback avatar is caused by missing avatar and fallbackIcon fields in the agent's personal details after account switching, since the real personal details for the agent account are not populated on the client after switching

    Root Cause

    When a user creates an agent via the CreateAgent API and then opens the account switcher to switch to the agent account, two problems occur:

    1. "Not here" page: After switching to the agent account, the app renders the Agents settings page (or navigates to a screen) where isCustomAgentEnabled is evaluated via isBetaEnabled(CONST.BETAS.CUSTOM_AGENT). The agent account session does not carry the CUSTOM_AGENT beta, so the page falls through to the NotFoundPage branch at line 96 of AgentsPage.tsx.

    2. Fallback avatar: The createAgent optimistic data populates PERSONAL_DETAILS_LIST with only accountID, displayName, and isOptimisticPersonalDetail — no avatar field. On success the optimistic entry is cleared, and the app has no avatar URL for the real agent account until personal details are reloaded. The avatar component falls back to the default fallback icon.

    Both issues are rooted in the App-side implementation of the agent creation and account-switching flow introduced in PR #89547.

  6. removed
    DeployBlocker
    on May 7, 2026
  7. MelvinBot commented on May 7, 2026

    @MelvinBot
    Contributor

    Issue Analysis

    This issue has two independent root causes, both introduced in #89547.

    Root Cause 1: "Not here" page after switching to agent

    When the account switcher calls Delegate.connect(), it runs clearOnyxForDelegateTransition() which wipes ONYXKEYS.BETAS — but does not reset React Navigation state. The user stays on the Agents settings route. AgentsPage.tsx:95-97 renders <NotFoundPage /> when the customAgent beta is missing. Since the agent account either (a) doesn't have the beta, or (b) betas haven't loaded yet from the openApp() response, the "Hmm... it's not here" page appears.

    Recommended Fix: The delegate connect flow should navigate to Home after switching accounts (similar to how sign-in lands on Home), rather than leaving stale navigation state pointing at beta-gated pages the new account may not have access to.

    Root Cause 2: Fallback avatar for agent

    Bot avatars are defined in DefaultBotAvatars.ts but are never registered in PresetAvatarCatalog.ts, which is the only source of truth for resolving avatar names to local SVGs. Additionally, createAgent() sets optimistic personalDetails with no avatar field, so the avatar is undefined during the optimistic period. Even after the server responds, the bot-avatar URL doesn't match DEFAULT_AVATAR_URL_PATTERNS so it can't resolve to a local SVG, causing the FallbackAvatar to render.

    Recommended Fix:

    1. Register bot avatars in PresetAvatarCatalog.ts so the avatar resolution pipeline can map bot-avatar IDs to local SVGs.
    2. Include the avatar in the optimistic personalDetails inside createAgent() so it renders immediately.
    Investigation details

    "Not here" page flow:

    1. User is on Settings > Agents page (has customAgent beta on main account)
    2. Taps agent in account switcher → AccountSwitcher.tsx:204-207 calls Delegate.connect()
    3. connect() calls clearOnyxForDelegateTransition() → Onyx.clear() wipes BETAS (not in preservation list)
    4. Navigation state is NOT reset — still on the agents route
    5. AgentsPage re-renders, isBetaEnabled(CONST.BETAS.CUSTOM_AGENT) returns false → <NotFoundPage />

    Avatar flow:

    1. AddAgentPage extracts bot avatar ID (e.g., bot-avatar--blue) and sends customExpensifyAvatarID to API
    2. Optimistic personalDetails entry has no avatar field → undefined → FallbackAvatar
    3. Server response includes avatar URL with bot-avatar identifier, but it doesn't match DEFAULT_AVATAR_URL_PATTERNS in UserAvatarUtils.ts
    4. PresetAvatarCatalog has no bot avatar entries, so resolution fails → FallbackAvatar persists

    Confidence: High — both root causes are clearly traceable in code.


    Next Steps: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  8. added
    Reviewing
    on May 7, 2026
  9. puneetlath commented on May 7, 2026

    @puneetlath
    Contributor

    This is expected for now. The BE for agent creation isn't all on production yet.

  10. removed
    DeployBlockerCash
    on May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugEngineeringHourlyReviewing

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions