[$175] Invoices - Internal Bill created from a submitted Invoice can't find the domain primary contact's "Submits To" and routes to the primary contact for approval first
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.5.27-2 Reproducible in staging?: Needs Reproduction (Reproduction blocked) Reproducible in production?: Needs Reproduction If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @abbagail Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
- A third party/contractor submits an Invoice to [email protected].
- The system automatically creates an internal Bill.
- The internal Bill is submitted to the "Submits To" of the domain's primary contact.
Expected Result:
The internal Bill goes straight into the approval process starting at the primary contact's "Submits To". After approval, the primary contact goes to the Invoice and marks it as paid.
Actual Result:
When the internal Bill is created, the system fails to find the primary contact's "Submits To". The Bill instead shows up as an Outstanding Bill for the primary contact to approve. Only after the primary contact approves does it move on to their "Submits To".
This adds an extra approval step by the primary contact that shouldn't exist.
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome / Safari
Screenshots/Videos
The screenshot for the issue is in Slack thread
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022117978554261919880
- Upwork Job ID: 2117978554261919880
- Last Price Increase: 2026-11-04
Issue Owner
Current Issue Owner: @AndrewGable
🤖 Web test steps verification results: ⚠️ partial
Reproduction blocked on dev NewDot web: this session has no workspaces or configured domains. No invoices were sent and no payments were approved.
| Step | Status |
|---|---|
Access a domain configured to receive contractor invoices at [email protected]Workspaces displayed “No workspaces yet.” Domains displayed only “Enhance your security with domains” and “New domain,” with no configured domain available.![]() |
❌ |
Inspect an automatically created internal Bill and its initial approval routingBlocked by the unavailable domain prerequisite; no corresponding internal Bill or approval routing could be inspected. A normal invoice flow was not substituted. |
❌ |
⚠️ Preliminary analysis (low confidence) — no routing defect confirmed.
Finding: Primary-contact-first routing matches the documented Bill Pay sequence. Confirm the intended behavior before proposing a fix.
Evidence and alternative explanations
- The Bill Pay guide describes primary-contact review before workspace approval (Receive-and-Pay-Bills.md:48–54). This challenges the failed-lookup hypothesis.
- Submits To governs your submitted reports; Approves To governs reports you have approved (Assign-report-approvers-to-specific-employees.md:60–65). Forwarding alone does not establish which setting supplied the next approver.
- App’s SendInvoice request:849–877 does not specify the receiving bill’s approver. This does not prove how inbound invoices are routed.
- Web reproduction was blocked: the session lacks a configured domain and affected bill. No production trace was verified.
To confirm: Clarify emailed attachment versus native invoice submission. Share the affected bill’s history and workspace approval settings internally. Confirm whether bypassing primary-contact review is intended. If so, escalate bill routing to an internal engineer; an App fix is not justified yet.
Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.
view run · no recording available
Triggered auto assignment to Contributor-plus team member for initial proposal review - @QichenZhu (External)
Job added to Upwork: https://www.upwork.com/jobs/~022117978554261919880
Proposal
Please re-state the problem that we are trying to solve in this issue.
An invoice submitted to a domain billing address reportedly generates an internal bill requiring the domain primary contact’s approval before reaching their configured “Submits To” approver. The requested behavior is to begin approval directly with that configured approver.
Triage verdict: insufficient evidence for a defensible implementation proposal. Reproduction remains unconfirmed, and no affected implementation or execution traces were supplied.
What is the root cause of that problem?
The root cause is not established. “Fails to find Submits To” is a hypothesis; the additional approval step does not prove a lookup failure.
There is also a material requirements conflict: Expensify’s official Classic Bill Pay documentation describes initial submission to the domain primary contact, followed by the workspace approval process. This makes intended behavior versus a regression a necessary product clarification. The documentation does not establish whether this particular submitted-invoice conversion should behave differently. Official Bill Pay workflow
The evidence does not distinguish between:
- A missing approver configuration in the workspace actually selected for the bill.
- Incorrect identity or workspace selection during conversion.
- Incorrect persisted approval routing.
- Correct persisted routing displayed incorrectly by the client.
- An intentional initial review step.
No verified defective file or line number is available. Source retrieval at 9.5.27-2 failed, and the private logs and screenshot were not available for inspection. Assigning this to a particular TypeScript function—or conclusively to the backend—would be speculation.
What changes do you think we should make in order to solve the problem?
No TypeScript diff is justified yet. Inventing paths, line numbers, fields, or routing mutations would fail the required evidence standard.
The minimum investigation needed to produce a surgical patch is:
- Reproduce with controlled accounts: contractor, domain primary contact P, and configured approver A, where P ≠ A.
- Record the selected workspace, its approval mode, and P’s effective “Submits To” configuration before submission.
- Capture the generated bill’s persisted owner, current approver, status, and approval history immediately after creation and after P approves.
- Compare persisted data with the displayed approval action to locate the defect.
- Confirm that this conversion is intended to bypass P’s initial review.
If persisted routing is wrong, fix the conversion or submission code that writes it. If persistence is correct, fix the specific client derivation that misrepresents it. Preserve invoice payment ownership separately from bill approval routing.
Expensify’s contribution rules require reproduction and access to the affected repository before a solution proposal can be accepted. Contribution requirements
What alternative solutions did you explore? (Optional)
No MelvinBot proposal was supplied, so there is no substantiated counterproposal to dismantle.
Reject these unsupported approaches:
- Hide P’s Approve button: leaves incorrect persisted routing unresolved.
- Automatically approve as P: records an approval that P did not perform.
- Globally skip primary contacts: could remove legitimate approval steps from unrelated workflows.
- Change an optimistic client value alone: cannot establish that automatic bill creation persists the correct route.
Existing proposals, fixes, and duplicate issues were not verified; originality cannot be claimed.
What automated tests can you add to prevent this from re-occurring?
Once the responsible implementation and intended behavior are confirmed, add a regression test at the layer that creates and routes the bill.
Proposed case: routes an invoice-generated bill directly to the primary contact's configured approver.
- Arrange P and distinct approver A in the selected workspace.
- Execute the actual invoice-to-bill conversion.
- Assert that the persisted first approver is A.
- Assert that no approval by P was recorded.
- Assert that invoice payment permissions remain correct.
- Assert that A’s approval follows the remaining configured workflow.
Also cover missing approver configuration, workspace-specific configuration, and configurations where P legitimately belongs in the approval chain. Their expected outcomes must follow confirmed product rules.
A Jest test that mocks the conversion response with an already-correct approver would not test the suspected routing defect. A server-owned conversion requires a server integration test; Jest can additionally verify client rendering.
Validation status: no reproduction, patch, or automated test was executed. An executable test file and exact diff cannot honestly be supplied from the available evidence.
Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01b60d704ba377be83
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
📣 @ronanchnlps-bit! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a workspace has an approval workflow where the domain's primary contact (technicalContactEmail / workspace owner) is configured to submit to another admin (Submits To: Admin B), and a vendor sends an Invoice to that domain ([email protected]), the internal Bill created in the receiver's workspace fails to route directly to Admin B. Instead, it routes to the domain's primary contact as an Outstanding Bill first, and only forwards to Admin B after the primary contact approves it.
What is the root cause of that problem?
There are two bugs in the approval workflow and employeeList lookup logic that cause the primary contact's submitsTo target to be lost or missed:
-
updateApprovalWorkflowoverwrites the default approver's customsubmitsTowith self-submission (src/libs/actions/Workflow.ts, lines 179–194): Insrc/libs/actions/Workflow.ts(lines 179–194), whenever the Default Workflow is created or updated (or when another workflow is saved while the primary contact is the Default Workflow's first approver, i.e.newDefaultApprover),updateApprovalWorkflowruns a backstop check onupdatedEmployees[newDefaultApprover]:if (newDefaultApprover) { const existing = updatedEmployees[newDefaultApprover] ?? previousEmployeeList[newDefaultApprover]; if (!existing || existing.submitsTo !== newDefaultApprover) { updatedEmployees[newDefaultApprover] = { ...existing, email: newDefaultApprover, submitsTo: newDefaultApprover, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }; ... } }- When the primary contact (
newDefaultApprover) has their own custom approval workflow (submitsTo: managerEmail), they are not in the Default Workflow'sapprovalWorkflow.members. - If the Default Workflow has a second-stage approver (
forwardsTo: managerEmail),convertApprovalWorkflowToPolicyEmployeescreatesupdatedEmployees[newDefaultApprover]withforwardsTo: managerEmailandsubmitsTo: undefined. - Even if
existingfalls back topreviousEmployeeList[newDefaultApprover](whereexisting.submitsTo === managerEmail), the conditionexisting.submitsTo !== newDefaultApproverevaluates totrue! - As a result,
updateApprovalWorkflowunconditionally overwritesupdatedEmployees[newDefaultApprover].submitsTotonewDefaultApprover(self-submission) while keepingforwardsTo: managerEmail. When an Invoice is received and converted into an internal Bill owned by the primary contact, the primary contact'ssubmitsTois now themselves (newDefaultApprover), so the Bill routes to the primary contact first and only routes toforwardsToafter they approve.
- When the primary contact (
-
Case-sensitive
policy.employeeListlookups insrc/libs/PolicyUtils/approvals.ts(lines 325, 366, 399, and 432): IngetApprovalWorkflow(line 325),getManagerAccountID(line 366),getManagerAccountEmail(line 399), andgetReportApproverAccountID(line 432),policy.employeeListis indexed directly with the rawownerLogin/submitterLogin(policy?.employeeList?.[ownerLogin ?? '']). However,policy.employeeListkeys are normalized to lowercase emails, whereas a domain invoice receiver or contact email (such as[email protected]or a mixed-case login) may contain uppercase characters. UnlikeisPolicyMemberandgetPolicyRoleinsrc/libs/PolicyUtils/permissions.ts(which fall back topolicy.employeeList[login.toLowerCase()]),approvals.tsmisses the employee entry when casing differs and falls back togetDefaultApprover(policy)(the primary contact).
What changes do you think we should make in order to solve the problem?
-
In
src/libs/actions/Workflow.ts(lines 179–194): Only apply thesubmitsTo: newDefaultApproverfallback whennewDefaultApproverdoes not already have a customsubmitsTotarget inpreviousEmployeeList(and preservepreviousEmployeeList[newDefaultApprover]?.submitsTowhenconvertApprovalWorkflowToPolicyEmployeestouchesupdatedEmployees[newDefaultApprover]only to setforwardsTo/overLimitForwardsTo):if (newDefaultApprover) { const previousDefaultApproverEmployee = previousEmployeeList[newDefaultApprover]; const existing = updatedEmployees[newDefaultApprover] ?? previousDefaultApproverEmployee; const existingSubmitsTo = updatedEmployees[newDefaultApprover]?.submitsTo ?? previousDefaultApproverEmployee?.submitsTo; if (!existing || !existingSubmitsTo) { updatedEmployees[newDefaultApprover] = { ...previousDefaultApproverEmployee, ...existing, email: newDefaultApprover, submitsTo: newDefaultApprover, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }; if (previousDefaultApproverEmployee) { previousEmployees[newDefaultApprover] = previousDefaultApproverEmployee; } employeesToClear[newDefaultApprover] = {pendingAction: null}; } else if (!updatedEmployees[newDefaultApprover]?.submitsTo && previousDefaultApproverEmployee?.submitsTo) { updatedEmployees[newDefaultApprover] = { ...updatedEmployees[newDefaultApprover], submitsTo: previousDefaultApproverEmployee.submitsTo, }; } } -
In
src/libs/PolicyUtils/approvals.ts(lines 325, 366, 399, and 432): Add a helpergetPolicyEmployee(policy, login)that checkspolicy?.employeeList?.[login] ?? policy?.employeeList?.[login.toLowerCase()]and use it ingetApprovalWorkflow,getManagerAccountID,getManagerAccountEmail, andgetReportApproverAccountID. -
In
tests/unit/WorkflowTest.tsandtests/unit/PolicyUtilsTest.ts: Add unit tests verifying that:- Updating the Default Workflow when
newDefaultApproveralready has a customsubmitsTodoes not overwritesubmitsTowithnewDefaultApprover. getManagerAccountEmailandgetManagerAccountIDresolvesubmitsTocase-insensitively.
- Updating the Default Workflow when
What alternative solutions did you explore?
We considered skipping the newDefaultApprover block in updateApprovalWorkflow only when approvalWorkflow.isDefault is true, but if an admin edits the Default Workflow's second approver (forwardsTo) after configuring a custom workflow for the default approver, convertApprovalWorkflowToPolicyEmployees still creates updatedEmployees[newDefaultApprover] without submitsTo. Preserving previousEmployeeList[newDefaultApprover]?.submitsTo handles both Default and non-Default workflow edits.
📣 @pa-khan! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Proposal
Please re-state the problem that we are trying to solve in this issue.
When an external party sends an invoice to a company domain address ([email protected]), the system converts the incoming invoice into an internal Bill under the domain's primary contact's default workspace. Instead of routing directly to the primary contact's configured Submits To approver in the workspace approval workflow, the Bill first routes to the domain primary contact for approval (saying it cannot find the Submits To target) and only advances to the rest of the workspace approval chain after the primary contact approves it.
What is the root cause of that problem?
The invoice-to-bill conversion and initial approver assignment happen entirely on the backend (Auth / Web-Expensify), not in the Expensify/App frontend:
- In
src/libs/actions/IOU/SendInvoice.ts, the frontendSendInvoicecommand only creates the sender's invoice report and transaction (getSendInvoiceInformation). It has no access to the recipient domain's internal workspace or approval workflow. - When an invoice is sent to
[email protected], the backend automatically generates a corresponding internalBillreport on the recipient's default workspace on behalf of thedomain_primary_contact. - Under Expensify's Bill Pay routing logic (or a backend lookup bug during auto-bill creation), the backend sets the
domain_primary_contactas the initialmanagerID/ first approver on the newly created Bill report rather than resolving thesubmitsTorule from the primary contact'spolicyEmployeeListentry before the first approval step.
What changes do you think we should make in order to solve the problem?
No frontend changes in Expensify/App are required:
- If product intends for bills created via
[email protected]to bypass the domain primary contact's initial review and route straight to theirSubmits Toapprover, the backend invoice-to-bill creation handler inWeb-Expensify/Authshould resolve thedomain_primary_contact'ssubmitsTotarget from the destination policy'semployeeList(falling back topolicy.approver/domain_primary_contactonly when nosubmitsTorule exists) when initializing the Bill report'smanagerIDandNEXT_ACTIONsystem message. - If routing to the
domain_primary_contactfirst is intentional (so the primary contact confirms receipt of the vendor invoice before forwarding it into the internal approval chain), then only the system message copy generated by the backend should be updated so it does not falsely claim that theSubmits Toapprover could not be found.
What alternative solutions did you explore? (Optional)
We checked whether the client ever triggers SubmitReport or sets managerID on the recipient's internal Bill report in src/libs/actions/IOU/SendInvoice.ts or src/libs/actions/Report/index.ts, and confirmed the recipient's Bill report is created asynchronously on the server without client involvement.
📣 @jeff-graham-ai! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
The bug is reported in both ND and Classic, so this is likely an Internal issue.
Triggered auto assignment to @AndrewGable, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Discussing in Slack here https://expensify.slack.com/archives/C049HHMV9SM/p1793734473118239
@AndrewGable @QichenZhu this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!