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
Agents - Company agent is not removed from table after deleting workspace until reset app #104647
Version Number: 9.5.16-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:#103817 Email or phone of affected tester (no customers):[email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.5 / Chrome App Component: Workspace Settings
Action Performed:
Precondition:
Enable companyAgents beta.
Go to staging.new.expensify.com
Go to workspace settings > Agents.
Create a company agent.
Delete the workspace.
Go to Account > Agents.
→ Company agent is shown in the table.
Go to Account > Troubleshoot > Clear cache and restart > Reset and refresh.
Go to Account > Agents.
→ Company agent is removed from the table.
Expected Result:
In Step 6, after deleting workspace, company agent should be removed from the table.
Actual Result:
In Step 6, after deleting workspace, company agent remains in the table.
In Step 7, after resetting app, company agent is removed from the table.
👋 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:
Identify the pull request that introduced this issue and revert it.
Causing PR:[Payment due @linhvovan29546] Create company agents (medium confidence). It adds the "New agent" button, which makes this bug reachable. The bug itself is a gap in the new Account > Agents table: it never hides agents whose owner workspace was deleted.
Recommendation: Fix forward. Don't revert. The feature is beta-only and not in production. The fix is App-only.
Fix: In src/hooks/useAgents.ts:83-86, skip workspace-owned agents when the owner policy is missing or pending delete:
useAgents lists every agent_* Onyx key. It only drops rows with no personal details or with the agent's own pending delete (L62-L76). A missing or deleted owner policy only leaves ownerDisplayName undefined. The row is still shown.
openAgentsPage runs each time the page mounts, but the stale row survives it. The response seems to merge agents without removing ones the server no longer returns. Only "Reset and refresh" clears Onyx, which matches the repro.
Why this PR
Before this PR, Workspace > Agents had no create button, and the old create path always sent isPersonalAgent: true. Users couldn't create a workspace-owned agent.
In deleteWorkspace, mark the workspace's agents pendingAction: DELETE optimistically, set them to null on success, and roll back on failure. This keeps offline behavior consistent.
On the backend, DeleteWorkspace could clear agent_<id> keys, and OpenAgentsPage could replace the collection instead of merging. That would also fix other devices. I couldn't verify the backend response from App code, and it isn't required to unblock the deploy.
Next Steps: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
Activity
applause-bot commentedon Oct 21, 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/3473f748b3d5f2f81b770705bf92ba234a441faf2b0bcde09891d80d5bc77d98
melvin-bot commentedon Oct 21, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #103817
melvin-bot commentedon Oct 21, 2026
@yuwenmemon @puneetlath @linhvovan29546 you have been assigned to this deploy blocker because you reviewed the offending PR: #103817
melvin-bot commentedon Oct 21, 2026
@s77rt you have been assigned to this deploy blocker because you authored the offending PR: #103817
melvin-bot commentedon Oct 21, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Oct 21, 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 Oct 21, 2026
Deploy Blocker Analysis
Causing PR: [Payment due @linhvovan29546] Create company agents (medium confidence). It adds the "New agent" button, which makes this bug reachable. The bug itself is a gap in the new Account > Agents table: it never hides agents whose owner workspace was deleted.
Recommendation: Fix forward. Don't revert. The feature is beta-only and not in production. The fix is App-only.
Fix: In
src/hooks/useAgents.ts:83-86, skip workspace-owned agents when the owner policy is missing or pending delete:Investigation details
Why the agent stays in the table
useAgentslists everyagent_*Onyx key. It only drops rows with no personal details or with the agent's own pending delete (L62-L76). A missing or deleted owner policy only leavesownerDisplayNameundefined. The row is still shown.deleteWorkspace(src/libs/actions/Policy/Policy.ts:435) never touches agent keys in its optimistic, success, or failure data.openAgentsPageruns each time the page mounts, but the stale row survives it. The response seems to merge agents without removing ones the server no longer returns. Only "Reset and refresh" clears Onyx, which matches the repro.Why this PR
isPersonalAgent: true. Users couldn't create a workspace-owned agent.Optional follow-ups
deleteWorkspace, mark the workspace's agentspendingAction: DELETEoptimistically, set them tonullon success, and roll back on failure. This keeps offline behavior consistent.DeleteWorkspacecould clearagent_<id>keys, andOpenAgentsPagecould replace the collection instead of merging. That would also fix other devices. I couldn't verify the backend response from App code, and it isn't required to unblock the deploy.Next Steps: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.view run
linhvovan29546 commentedon Oct 22, 2026
s77rt commentedon Oct 22, 2026
I think this is a low value issue for two reasons:
Screen.Recording.2026-10-22.at.7.51.42.PM.mov
As for Melvin suggested solution that won't work because we can't know if the agent is going to be deleted (it may be transferred).
Closing