You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-08-12] Immediately open the agent DM after creating a new agent #94395
After creating a new agent, it appears on the agents page but there's no clear next action. The actual next step is to open a DM with the agent, but nothing guides the user there — they have to discover it on their own.
Proposed solution
Immediately open the DM with the newly created agent right after creation (or provide a clear deep link / next-step CTA to it), so users land directly in the conversation where they can start using the agent.
Context
Came out of feedback on the new custom agent creation flow — there was no clear next action after creation, which left users unsure how to proceed.
Implementation Plan: Open the agent DM right after creation
TL;DR: All the pieces already exist. createAgent already returns the new agent's optimisticAccountID, and the useChatWithAgent hook already knows how to open a DM by accountID (it's what each row on the Agents list uses). The fix is to stop discarding that accountID in AddAgentPage.handleSubmit and hand it to chatWithAgent(...) instead of just calling Navigation.goBack().
The one change that matters
AddAgentPage.handleSubmit currently ignores the return value of createAgent and does a plain Navigation.goBack(), landing the user back on the Agents list with no next step.
// add alongside the other hooks near the top of the componentconstchatWithAgent=useChatWithAgent();consthandleSubmit=(values: FormOnyxValues<typeofONYXKEYS.FORMS.ADD_AGENT_FORM>)=>{constfirstName=values[INPUT_IDS.FIRST_NAME].trim()||defaultAgentName;constprompt=values[INPUT_IDS.PROMPT].trim();constpendingFile=pendingFileRef.current;const{optimisticAccountID}=pendingFile
? createAgent(firstName,prompt,undefined,pendingFile.file,pendingFile.uri,policyID)
: createAgent(firstName,prompt,selectedPresetID??undefined,undefined,undefined,policyID);// Replaces Navigation.goBack() — drop the user straight into the DM with the new agent.chatWithAgent(optimisticAccountID);};
This stays fully offline-first and matches the existing "pure optimistic flow" comment: createAgent returns {optimisticAccountID, avatarURI}, and useChatWithAgent → navigateToAndOpenReportWithAccountIDs([accountID], ...) optimistically builds + opens the DM report client-side.
⚠️ The one thing to verify first
The client generates optimisticAccountID via generateReportID() and sends it to the backend in the CreateAgent params (Agent.ts:100). The whole plan hinges on the backend honoring that client-supplied accountID as the agent's real, permanent accountID (the standard optimistic-ID pattern). If it does, the DM opened against it stays valid after the server responds — done.
If instead the backend assigns a different accountID, opening the DM optimistically would point at a phantom account (the successData nulls the optimistic personal detail), and the plan changes: you'd need CreateAgent to return the real accountID and open the DM from the success callback (awaiting the write), giving up the pure-optimistic UX. Confirm the backend behavior before implementing — it determines which of the two paths above is correct.
Supporting detail: files, existing precedent, and navigation notes
Create action:createAgent fires WRITE_COMMANDS.CREATE_AGENT and already returns {optimisticAccountID, avatarURI} — currently discarded by the caller.
Existing DM-open precedent: each row on AgentsPage already wires onChatPress={chatWithAgent} from the same hook, so opening a DM by agent accountID is a proven, in-use path — we're just triggering it one step earlier.
Underlying action:navigateToAndOpenReportWithAccountIDs does getChatByParticipants → buildOptimisticChatReport + openReport → navigateToReport(ROUTES.REPORT_WITH_ID).
Navigation stack:AddAgentPage is a settings/RHP screen. Verify that navigating to the report cleanly dismisses the RHP/modal so the DM lands in the central pane (rather than stacking under the settings modal). If it doesn't dismiss on its own, dismiss the modal before/as part of the navigation.
Scope: this is a single-file change in AddAgentPage.tsx (plus the backend confirmation above). No new hook, action, or route is needed.
Testing: create an agent online and offline; confirm you land in the DM, the agent renders (optimistic → reconciled), and the DM remains the same report after the server responds (the key regression to watch given the optimistic-accountID question above).
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/94395#issuecomment-4902205853) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting this plan.
What it does:AddAgentPage.handleSubmit now captures the optimisticAccountID returned by createAgent and opens the DM with the new agent via the existing useChatWithAgent hook, instead of just calling Navigation.goBack(). Fully optimistic/offline-first — no waiting on the server.
Checks run locally (all green):npm run fmt, lint-changed, typecheck-tsgo, React Compiler compliance, and the AddAgentPage + Agent action unit tests (64 passed). I updated the two AddAgentPage submit tests to assert the new "open the DM" behavior.
⚠️One thing to confirm during review (flagged in the plan): this relies on the backend honoring the client-supplied optimisticAccountID as the agent's permanent accountID. If the server assigns a different accountID, the DM would need to open from the CreateAgent success response instead. Worth verifying the DM stays the same report after the server reconciles.
Please fill out the Tests/QA sections and mark it as "Ready for review" when it's ready.
Activity
mjasikowski commentedon Jul 7, 2026
@MelvinBot create an implementation plan
MelvinBot commentedon Jul 7, 2026
Implementation Plan: Open the agent DM right after creation
TL;DR: All the pieces already exist.
createAgentalready returns the new agent'soptimisticAccountID, and theuseChatWithAgenthook already knows how to open a DM by accountID (it's what each row on the Agents list uses). The fix is to stop discarding that accountID inAddAgentPage.handleSubmitand hand it tochatWithAgent(...)instead of just callingNavigation.goBack().The one change that matters
AddAgentPage.handleSubmitcurrently ignores the return value ofcreateAgentand does a plainNavigation.goBack(), landing the user back on the Agents list with no next step.This stays fully offline-first and matches the existing "pure optimistic flow" comment:
createAgentreturns{optimisticAccountID, avatarURI}, anduseChatWithAgent→navigateToAndOpenReportWithAccountIDs([accountID], ...)optimistically builds + opens the DM report client-side.The client generates
optimisticAccountIDviagenerateReportID()and sends it to the backend in theCreateAgentparams (Agent.ts:100). The whole plan hinges on the backend honoring that client-supplied accountID as the agent's real, permanent accountID (the standard optimistic-ID pattern). If it does, the DM opened against it stays valid after the server responds — done.If instead the backend assigns a different accountID, opening the DM optimistically would point at a phantom account (the
successDatanulls the optimistic personal detail), and the plan changes: you'd needCreateAgentto return the real accountID and open the DM from the success callback (awaiting the write), giving up the pure-optimistic UX. Confirm the backend behavior before implementing — it determines which of the two paths above is correct.Supporting detail: files, existing precedent, and navigation notes
createAgentfiresWRITE_COMMANDS.CREATE_AGENTand already returns{optimisticAccountID, avatarURI}— currently discarded by the caller.AgentsPagealready wiresonChatPress={chatWithAgent}from the same hook, so opening a DM by agent accountID is a proven, in-use path — we're just triggering it one step earlier.navigateToAndOpenReportWithAccountIDsdoesgetChatByParticipants→buildOptimisticChatReport+openReport→navigateToReport(ROUTES.REPORT_WITH_ID).AddAgentPageis a settings/RHP screen. Verify that navigating to the report cleanly dismisses the RHP/modal so the DM lands in the central pane (rather than stacking under the settings modal). If it doesn't dismiss on its own, dismiss the modal before/as part of the navigation.AddAgentPage.tsx(plus the backend confirmation above). No new hook, action, or route is needed.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/94395#issuecomment-4902205853)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting this plan.
mjasikowski commentedon Jul 7, 2026
@MelvinBot implement [this](#94395 (comment)
MelvinBot commentedon Jul 7, 2026
🤖 Draft PR created: #95482
What it does:
AddAgentPage.handleSubmitnow captures theoptimisticAccountIDreturned bycreateAgentand opens the DM with the new agent via the existinguseChatWithAgenthook, instead of just callingNavigation.goBack(). Fully optimistic/offline-first — no waiting on the server.Checks run locally (all green):
npm run fmt,lint-changed,typecheck-tsgo, React Compiler compliance, and theAddAgentPage+Agentaction unit tests (64 passed). I updated the twoAddAgentPagesubmit tests to assert the new "open the DM" behavior.optimisticAccountIDas the agent's permanent accountID. If the server assigns a different accountID, the DM would need to open from theCreateAgentsuccess response instead. Worth verifying the DM stays the same report after the server reconciles.Please fill out the
Tests/QAsections and mark it as "Ready for review" when it's ready.19 remaining items