Repository navigation
Description
Part of the Custom workflow agents project
Main issue: https://github.com/Expensify/Expensify/issues/614622
Doc section: https://expensify.enterprise.slack.com/docs/T03SC9DTT/F0AKV1FPD41?focus_section_id=temp:C:PDZ796de256f74140a4b85536d69
Feature Description
Add a "Create an agent" row to the top of the Set Approver page so that workspace admins can create an agent and set it as the approver without leaving the workflow editing context.
- Clicking "create an agent" will launch the create agent modal
- Upon creating the agent, we call the API to create the agent and add them to the workspace as a regular member simultaneously
- We'll drop the user back on the "edit approval workflow" page with the newly created agent set
src/components/ApproverSelectionList.tsx
Add a new headerContent: React.ReactNode | undefined prop. Render it inside the <SelectionList> headerContent slot, above the list rows (the same slot SelectionList already supports for prepending custom rows).
src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsApproverPage.tsx
Build the "Create an agent" header row and pass it via headerContent only when all of the following are true:
- The
customAgentbeta is active. isChangeApproverRoute === false.approverIndex === 0.
Tapping the row navigates to SETTINGS_AGENTS_ADD with both policyID and workflowApproverEmail set.
Return flow after agent creation
AddAgentPage.onSubmit calls Navigation.goBack(), returning the user to the Set Approver page. At that point:
- The optimistic Onyx write from
createAgent()combined with the server-sideCreateAgentresponse (which writes the agent intopolicy.employeeListatomically via thepolicyIDpath — see the companion backend issue) produces apolicy.employeeListentry for the new agent. setApprovalWorkflowApprover()(gated onpolicyIDbeing set) marks the new agent as the currently-selected approver inONYXKEYS.APPROVAL_WORKFLOW, reusing the same store-shape thattoggleApproveralready writes when a row is tapped.- The new agent's row appears in
allApproversand the picker shows it as already selected.
Manual Test Steps
- Enable the
customAgentbeta on a test workspace. - Go to Workspace > Workflows, open a workflow for editing, and tap the approver field to reach the Set Approver page.
- Verify a "Create an agent" row appears at the top of the approver list.
- Tap "Create an agent" — verify the create-agent modal launches with the workspace context.
- Complete the create-agent flow — verify you return to the Set Approver page with the new agent's row visible and already selected.
- Confirm the workflow and verify the agent is saved as the approver.
- Repeat all steps on a workspace where the
customAgentbeta is not enabled — verify the "Create an agent" row never appears.
Automated Tests
- A test that
ApproverSelectionListrenders theheaderContentnode above the list rows when the prop is supplied, and renders nothing extra when the prop is absent. - A test that
WorkspaceWorkflowsApprovalsApproverPagepasses the "Create an agent" header row toApproverSelectionListonly when thecustomAgentbeta is on,isChangeApproverRouteis false, andapproverIndexis 0. - A test that after
AddAgentPage.onSubmit, the new agent is marked as the selected approver inONYXKEYS.APPROVAL_WORKFLOW.
Activity
NicolasBonet commentedon May 27, 2026
Not overdue, will start tomorrow, hopefully
NicolasBonet commentedon Jun 3, 2026
PR opened...
NicolasBonet commentedon Jun 5, 2026
This is deprioritized now in favor of AI Rules, will check later
NicolasBonet commentedon Jun 12, 2026
mallenexpensify commentedon Jun 16, 2026
Payment Summary
Contributor+: @ShridharGoel due $250 via NewDot
PR was reviewed and tests were completed, so 100%
garrettmknight commentedon Jun 19, 2026
$250 approved for @ShridharGoel