[Due for payment 2026-08-07] Agents - Wrong avatar is shown on the template agent after refreshing page #97388
Description
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.46-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: #95991
Email or phone of affected tester (no customers): iosjdnojsdoijdisojiso@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:
- Go to staging.new.expensify.com
- Go to Account > Agents.
- Click New agent.
- Click Add on TipMaster.
- Refresh the page.
- Click RHP back button.
- Click Add on Translator Tess.
→ Blue avatar is shown instead of green avatar. - Click RHP back button.
- Click Add on Translator Tess.
→ The correct green avatar is shown when reopening Translator Tess for the second time.
Expected Result:
In Step 7, after refreshing page and changing agent template, correct avatar will be shown for the selected template.
Actual Result:
In Step 7, after refreshing page and changing agent template, the previous avatar is shown for newly selected template.
In Step 9, the correct green avatar is shown when reopening Translator Tess for the second time.
Workaround:
Unknown
Platforms:
- Android: App
- Android: mWeb Chrome
- iOS: App
- iOS: mWeb Safari
- iOS: mWeb Chrome
- Windows: Chrome
- MacOS: Chrome Safari
Screenshots/Videos
Bug7221274_1785359499375.3.mp4
Applause Internal Information
Exported by: Svetlana Lazutkina
Bug ID: 7221274
Issue Owner
Current Issue Owner: @mallenexpensifyMetadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
applause-bot commentedon Jul 29, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/83f8404ce8bd49f356ebb7cc93d6960f079fc3b7ebefe4772d3772e39d661bce
melvin-bot commentedon Jul 29, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #95991
melvin-bot commentedon Jul 29, 2026
@yuwenmemon @gijoe0295 you have been assigned to this deploy blocker because you reviewed the offending PR: #95991
melvin-bot commentedon Jul 29, 2026
@shubham1206agra you have been assigned to this deploy blocker because you authored the offending PR: #95991
melvin-bot commentedon Jul 29, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Jul 29, 2026
👋 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:
MelvinBot commentedon Jul 29, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #95991 - "Add agent template picker structure" by
shubham1206agra(High confidence)Related Issues: #94394 (feature issue this PR implemented)
Recommendation: ROLL FORWARD
This is a brand-new feature (not in production) and the root cause is a small, self-contained avatar-draft seeding bug. A targeted one-line fix (clear the stale avatar draft when a template is picked) is far safer than reverting the entire 14-commit feature PR. The bug is also cosmetic and self-heals on the second open, so a quick roll-forward fix is appropriate.
Assigned:
shubham1206agra(PR author),gijoe0295andyuwenmemon(approving reviewers) — already assigned to this issue.Labels: No changes. Kept
DeployBlockerCash(App/frontend deploy is blocked).DeployBlockerwas not present, so nothing to remove.📋 Detailed Analysis
Evidence
src/pages/settings/Agents/NewAgentPage.tsx,src/pages/settings/Agents/AddAgentPage.tsx, andsrc/libs/actions/Agent.ts.StagingDeployCashchecklist (Deploy Checklist: New Expensify 2026-07-29 #97375), merged 2026-07-28, and the issue confirms the feature does not exist in production — matching "Reproducible in production?: N/A - new feature."Verification
Affected files, all authored by this PR:
src/pages/settings/Agents/AddAgentPage.tsx— derives the displayed avatar from the persisted draft and seeds it.src/pages/settings/Agents/NewAgentPage.tsx— stashes the picked template and navigates into the builder.src/libs/actions/Agent.ts—setNewAgentTemplate/setNewAgentAvatarPreset/clearNewAgentAvatarDraftOnyx writers.The avatar on the Add screen is driven only by the persisted Onyx draft
AGENT_NEW_AVATAR_DRAFT, not by the selected template directly:AddAgentPage.tsx#L63-L90—selectedPresetIDandavatarSourcecome fromavatarDraft.Root Cause
The seed effect writes the template's preset into the draft only when no draft already exists:
AddAgentPage.tsx#L73-L83— the guardif (hasSeededRef.current || isDraftLoading || avatarDraft) { return; }bails whenever any draft is present. It never reconciles the draft against a newly-selectedtemplate.AGENT_NEW_AVATAR_DRAFTis a single global Onyx key that is intentionally designed to survive a page refresh (see the comment at lines 70–72 andsetNewAgentAvatarPreset/clearNewAgentAvatarDraftinAgent.ts#L357-L370). It is cleared in only two places: on submit (AddAgentPage.tsx#L123) and in theuseBeforeRemovecleanup when the user backs out without submitting (AddAgentPage.tsx#L92-L100).Step-by-step for the repro:
NEW_AGENT_TEMPLATE= TipMaster, builder seedsAGENT_NEW_AVATAR_DRAFT= TipMaster's (blue) preset. Correct.useBeforeRemove, which relies on React Navigation'sbeforeRemoveevent — a mechanism the hook itself flags as limited (useBeforeRemove.tsx). After a hard refresh into the deep-linked RHP, the back-navigation does not reliably firebeforeRemovefor the refreshed screen, soclearNewAgentAvatarDraft()never runs and the blue draft leaks.NEW_AGENT_TEMPLATE= Translator Tess (green). The builder re-opens, but the stale blue draft is still in Onyx, so the seed guard bails (avatarDraftis truthy) andselectedPresetIDresolves to the leftover blue ID → wrong avatar.beforeRemovenormally (no refresh in play), clearing the draft. Re-opening Translator Tess seeds green correctly — which is exactly why the second open is right.The underlying flaw: the avatar draft is a global key not scoped to the selected template, and the seed logic conflates "a draft exists" with "the user deliberately chose this avatar," so a leftover draft from a previous template silently overrides the newly-picked template's avatar.
Suggested targeted fix (roll forward)
Clear the leftover draft at the two points where the user deliberately starts a fresh builder session, in
NewAgentPage.tsx#L94-L106(handleBuildCustomAgentandhandleAddTemplate): callclearNewAgentAvatarDraft()alongside setting/clearing the template before navigating. This resets the avatar per template selection while still letting the draft survive a mid-session refresh, since picking a template is a distinct user action from a refresh. Alternatively, make the seed effect reconcile the draft's preset againsttemplate.avatarIDwhen the user has not explicitly overridden the avatar.Next Steps: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.12 remaining items
melvin-bot commentedon Aug 3, 2026
@shubham1206agra Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
shubham1206agra commentedon Aug 4, 2026
@yuwenmemon You can close this issue
melvin-bot commentedon Aug 6, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Aug 6, 2026
Payment Summary
Resolving PRs:
Fix - Wrong avatar is shown on the template agent after refreshing page #97449
Reviewer: @shubham1206agra owed $250 via NewDot
Reviewer: @gijoe0295 owed $250 via NewDot
BugZero Checklist (@mallenexpensify)
shubham1206agra commentedon Aug 7, 2026
@mallenexpensify Nobody is required payment here