Skip to content

Add "Create an agent" row to the Set Approver page #91245

Closed

Description

@puneetlath

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.

Image
  • 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 customAgent beta 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-side CreateAgent response (which writes the agent into policy.employeeList atomically via the policyID path — see the companion backend issue) produces a policy.employeeList entry for the new agent.
  • setApprovalWorkflowApprover() (gated on policyID being set) marks the new agent as the currently-selected approver in ONYXKEYS.APPROVAL_WORKFLOW, reusing the same store-shape that toggleApprover already writes when a row is tapped.
  • The new agent's row appears in allApprovers and the picker shows it as already selected.

Manual Test Steps

  1. Enable the customAgent beta on a test workspace.
  2. Go to Workspace > Workflows, open a workflow for editing, and tap the approver field to reach the Set Approver page.
  3. Verify a "Create an agent" row appears at the top of the approver list.
  4. Tap "Create an agent" — verify the create-agent modal launches with the workspace context.
  5. Complete the create-agent flow — verify you return to the Set Approver page with the new agent's row visible and already selected.
  6. Confirm the workflow and verify the agent is saved as the approver.
  7. Repeat all steps on a workspace where the customAgent beta is not enabled — verify the "Create an agent" row never appears.

Automated Tests

  • A test that ApproverSelectionList renders the headerContent node above the list rows when the prop is supplied, and renders nothing extra when the prop is absent.
  • A test that WorkspaceWorkflowsApprovalsApproverPage passes the "Create an agent" header row to ApproverSelectionList only when the customAgent beta is on, isChangeApproverRoute is false, and approverIndex is 0.
  • A test that after AddAgentPage.onSubmit, the new agent is marked as the selected approver in ONYXKEYS.APPROVAL_WORKFLOW.
Issue OwnerCurrent Issue Owner: @NicolasBonet
Issue OwnerCurrent Issue Owner: @NicolasBonet

Activity

  1. NicolasBonet commented on May 27, 2026

    @NicolasBonet
    Contributor

    Not overdue, will start tomorrow, hopefully

  2. added
    Reviewing
    Weekly
    and removed
    Daily
    Weekly
    on May 27, 2026
  3. NicolasBonet commented on Jun 3, 2026

    @NicolasBonet
    Contributor

    PR opened...

  4. NicolasBonet commented on Jun 5, 2026

    @NicolasBonet
    Contributor

    This is deprioritized now in favor of AI Rules, will check later

  5. NicolasBonet commented on Jun 12, 2026

    @NicolasBonet
    Contributor
  6. mallenexpensify commented on Jun 16, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @ShridharGoel due $250 via NewDot

    PR was reviewed and tests were completed, so 100%

  7. garrettmknight commented on Jun 19, 2026

    @garrettmknight
    Contributor

    $250 approved for @ShridharGoel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ReviewingWeekly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions