Skip to content

[HOLD Auth#26177] Open, approve and pay existing bills in New Expensify - #105499

Closed
cead22 wants to merge 20 commits into
mainfrom
carlos-billpay-existing-bills
Closed

cead22 wants to merge 20 commits into
mainfrom
carlos-billpay-existing-bills

Conversation

@cead22

@cead22 cead22 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR lets users open, approve and pay existing bills in New Expensify. Bills come from Expensify Classic or from invoices that vendors email to a domain's bill pay address. Before this PR, New Expensify showed bills as an unsupported report type.

  • Approvals work on Bills. Bills can't be rejected, because RejectExpenseReport returns "400 Bills are not supported". Approvers send a bill back with Unapprove instead.
  • New pay button. BillPaymentButton pays bills and received invoices. The button shows the amount, for example Pay $125.00. The menu lists each of the payer's business bank accounts with the bank's logo and last four digits, like the Pay menu on expense reports. Bills are paid with PayMoneyRequest, by ACH from the chosen account or with Mark as paid. This needs Auth #26177. Received invoices still pay by ACH with ReimburseReport and are marked as paid with MarkReimbursed. When the payer has no business bank account, the menu offers Pay with business account, which starts adding one. These work without a parent chat, because bills have none. ACH payments are only in USD, so bills in other currencies only offer Mark as paid. Auth's Report::getBillPayFilter treats every invoice the user receives without a linked bill as Bill Pay, so received invoices use the same button.
  • Payment rules. BillPayUtils holds the shared rules for who can approve and pay a bill. Pay shows on approved bills when payments are enabled on the policy. As in Classic, the bill's receiver, the policy's reimburser, and the policy's admins and payments admins can pay.
  • Payment history. PayMoneyRequest adds an IOU PAY action to the bill, and the app shows it right away. Invoices get no IOU PAY action, either when ReimburseReport and MarkReimbursed pay them or when their linked bill is paid, so invoices show their payment action instead.
  • Waiting for a bank account. The waiting message names the vendor, who must add a bank account, not the bill's owner. The vendor's invoice also shows the waiting message and its next step, which asks the vendor to add a bank account. Invoices show no other next steps. The Inbox shows a green dot on the invoice while Auth's isAwaitingActionFromCurrentUser says it waits on the vendor, and names the payer when the vendor's App has no name for them. These parts need Auth PRs stacked on [TS migration] Migrate 'shouldDelayFocus' lib to TypeScript #26177: the waiting message on the invoice needs Auth #26218, the vendor's name on the bill needs Auth #26219, and the green dot needs Auth #26220. Without them, App shows no message, "Hidden" or no green dot, and nothing breaks.
  • Canceling a payment. Canceling a payment works without a chat report. A bill canceled on a policy without approvals is Submitted and Closed. It shows Done and can be paid again.
  • Inbox and badges. The approver sees the Approve badge on the bill itself, because there is no parent chat preview to carry it. The receiver doesn't see the invoice that is linked to a bill.
  • Bill header. The subtitle shows only the report status and policy name. Bills have no parent chat, so the subtitle has no link, "From", or "in". Auth #26245 supplies policyName when App has no policy record.
  • Bill approval next step. Bills waiting for approval say "Waiting for you to approve the bill." The message also names another approver or an admin when appropriate. Expense reports keep "approve expenses". This copy change needs no Auth change.

Notes for the code review:

  • useBillPayCounts and useCanCreateBill come in later PRs of this stack.
  • actions/BillPay.ts exports payBill as its default export, because it is the only export. The Create bill PR adds createBill and switches to named exports.
  • The header fix leaves the existing BillPaymentButton interface and its prop comment unchanged. The button uses the current ButtonWithDropdownMenu interface to match expense report payments. Refactoring that interface falls outside this header fix.
  • English and Spanish include the bill approval copy. The PR translation workflow must generate the remaining locales. Local translation generation has no API key.
  • Browser verification of the header and approval copy remains pending because no dev server is running.

Fixed Issues

For https://github.com/Expensify/Expensify/issues/684654
PROPOSAL:

Reported in:

Tests

  1. As a vendor, email a PDF invoice to the receiving domain's bill pay address, for example receiver.com@expensify.cash. That creates a submitted bill for the domain.
  2. Sign in to New Expensify as the bill's approver.
  3. Open the bill from the Inbox, or go to /r/<billReportID>.
  4. Verify the header shows Approve, and the More menu has no Reject.
  5. Approve the bill.
  6. Sign in as the policy's payer and open the same bill.
  7. Verify the header shows Pay with the bill's amount, and its menu shows your business bank account, with its logo and last four digits, and Mark as paid.
  8. Select Mark as paid.
  9. Verify the bill shows Paid, and the report shows the payment action.
  10. Repeat steps 1 to 6 with a vendor who has no bank account, then select Pay and your business bank account.
  11. Verify the bill moves back to Approved
    • Note The next step won't show right away, as it depends on an Auth fix, but if you refresh the page, the next step will say that it's waiting for the vendor to add the bank account.
  12. Cancel the payment from the More menu.
  13. Verify the bill can be paid again.
  14. Sign in as a payments admin of the policy who has no business bank account, and open an approved bill.
  15. Select Pay and verify the menu shows Pay with business account and Mark as paid.
  16. Select Pay with business account and verify the add bank account flow opens.
  17. As the payer, open an approved bill on a policy whose default currency isn't USD, for example GBP. The bill's own currency must not be USD. A EUR expense on a USD policy makes a USD bill.
  18. Verify the Pay menu only shows Mark as paid.
  19. Sign in as the receiver of a vendor invoice that is linked to a bill.
  20. Verify the Inbox shows the bill, not the linked invoice.
  21. Open the bill and verify its subtitle shows only the report status and policy name.
  22. Verify the subtitle has no chat link, "From", or "in".
  23. Share the bill with a reader who isn't a policy member and open it as that reader.
  24. Verify the header still shows the policy name.
  25. Open an expense report with a parent chat and verify its subtitle still links to that chat.
  26. Open a submitted bill as its approver. Verify the next step says "Waiting for you to approve the bill."
  27. Open the same bill as another reader. Verify the next step names the approver and says "approve the bill."
  28. Reload the bill and verify the next step still says "approve the bill."
  29. Open an expense report waiting for approval. Verify its next step still says "approve expenses."
  • Verify that no errors appear in the JS console

Offline tests

  1. Open an approved bill as its payer.
  2. Go offline.
  3. Select Pay > Mark as paid.
  4. Verify the bill shows Paid with a pending state.
  5. Go online.
  6. Verify the payment finishes and the pending state clears.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@cead22
cead22 requested a review from a team as a code owner October 30, 2026 15:07
@cead22
cead22 requested a review from a team as a code owner October 30, 2026 15:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T15:12:42.442164Z ce136cd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@melvin-bot

melvin-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

@puneetlath Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@OSBotify

This comment has been minimized.

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 95.96% <ø> (ø)
src/components/MoneyReportHeaderNextStep.tsx 76.92% <100.00%> (+76.92%) ⬆️
...neyReportHeaderPrimaryAction/useConfirmApproval.ts 98.24% <100.00%> (+0.06%) ⬆️
src/components/MoneyReportHeaderStatusBar.tsx 100.00% <100.00%> (+100.00%) ⬆️
...h/SearchList/ListItem/ActionCell/PayActionCell.tsx 88.54% <100.00%> (-7.07%) ⬇️
...hooks/useMoneyReportHeaderMoreContentVisibility.ts 100.00% <100.00%> (ø)
src/libs/API/types.ts 100.00% <ø> (ø)
src/libs/BillPayUtils.ts 100.00% <100.00%> (ø)
src/libs/Formula.ts 91.02% <ø> (ø)
src/libs/NextStepUtils.ts 91.57% <100.00%> (+0.66%) ⬆️
... and 18 more
... and 10 files with indirect coverage changes

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

🚧 cead22 has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚧 trjExpensify has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@cead22 cead22 changed the title [HOLD] Open, approve and pay existing bills in New Expensify [HOLD Auth#26177] Open, approve and pay existing bills in New Expensify Nov 3, 2026
@OSBotify

OSBotify commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🦜 Polyglot Parrot! 🦜

Squawk! Looks like you added some shiny new English strings. Allow me to parrot them back to you in other tongues:

The diff is too large to include in this comment (138KB), so I've created a gist for you:

📋 View the translation diff here 📋

Note

You can apply these changes to your branch by copying the patch to your clipboard, then running pbpaste | git apply, or directly by running gh gist view --raw 66a223308ae0a3da4449ff64d6d58211 | git apply 😉

View workflow run

@roryabraham

Copy link
Copy Markdown
Contributor

Tested the single transaction report flow on bill intake, worked for me 👍🏼

image

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🚧 cead22 has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@mananjadhav mananjadhav left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left review comments.

Comment thread src/libs/ReportUtils.ts
function isExpenseReport(reportOrID: OnyxInputOrEntry<Report> | string): boolean {
const report = typeof reportOrID === 'string' ? (getReport(reportOrID, deprecatedAllReports) ?? null) : reportOrID;
return report?.type === CONST.REPORT.TYPE.EXPENSE;
return report?.type === CONST.REPORT.TYPE.EXPENSE || report?.type === CONST.REPORT.TYPE.BILL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**question: ** isExpenseReport is now true for bills, and the More menu has no bill exception except Reject, so a submitted bill can show Retract, Add expense, Delete, and Change approver, and a Closed bill can show Reopen.

* An ACH payment debits the payer's account in USD, so only open USD accounts that allow debits can pay. The
* Expensify Card settlement account only settles card spend.
*/
function payableBankAccountsSelector(bankAccounts: OnyxEntry<BankAccountList>): BankAccountList {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: payableBankAccountsSelector does not require accountData.type === BUSINESS, unlike getBusinessBankAccountOptions, so a personal USD account with allowDebit is offered for ACH and the policy withdrawal account is not listed first.


if (isBillReport(moneyRequestReport) || isInvoiceReport) {
return (
<BillPaymentButton

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every invoice is sent through BillPaymentButton (same switch in PayActionButton.tsx:173 and PayActionCell.tsx:227), so a normal invoice room no longer calls PayInvoice and loses wallet and personal-bank payment. The PR text says received invoices should use ReimburseReport / MarkReimbursed — is dropping PayInvoice for those rooms intended?

<ActionableItemButtons layout="horizontal">
<Button
variant={CONST.BUTTON_VARIANT.SUCCESS}
onPress={() => openPersonalBankAccountSetupView({exitReportID: targetReport?.reportID, isUserValidated})}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the invoice, this button still calls openPersonalBankAccountSetupView, which adds a personal deposit account, while the new queued-payment copy no longer says "personal."

const isWaitingOnSenderBankAccount = moneyRequestReport?.nextStep?.messageKey === CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_SUBMITTER_ACCOUNT;
const isInvoiceReport = isInvoiceReportUtil(moneyRequestReport);
const shouldShowNextStep = isGroupPolicy(policy) && !isInvoiceReport && !shouldShowStatusBar;
const shouldShowNextStep = (isInvoiceReport ? isWaitingOnSenderBankAccount : isGroupPolicy(policy)) && !shouldShowStatusBar;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bill's next step still requires isGroupPolicy(policy), so a viewer who has the report next step but no policy record sees the policy name in the header and no "approve the bill" message.

Comment thread tests/unit/BillPayTest.ts
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
};

it('moves a bill from approval to payment only after final approval', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moves a bill from approval to payment, includes received standalone invoices, and keeps business invoices visible, plus BillPayAttentionTest.ts:50, have no Given / When / Then comments. tests/README.md requires those on every test.

expect(startApprovedAnimation).toHaveBeenCalled();
});

it('does not start the approved animation for a bill', async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approveMoneyRequest is mocked and the bill has no chatReportID. The test cannot see a failed approval merge into report_undefined, or a partial approve that skips the hold-report split because there is no chat.

mockFetch?.resume?.();
});

it('sends a cancellation request for a bill without a chat report', async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cancel is covered for an admin on someone else's bill. It never checks Mark as paid by the owner when that owner is not the reimburser, an admin, or a payments admin, which is the case where Cancel disappears.


it('calls payInvoice with the chatReport supplied as a prop (the flat `type:invoice columns:...` transaction row now resolves and passes it)', async () => {
// Given an invoice report row whose invoice chat is resolved and passed down as a prop
it('offers the bill payment flow for an invoice with a parent room', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the invoice-with-a-room case and the no-room case expect BillPaymentButton and assert payInvoice is not called. That freezes the removal of PayInvoice, wallet, and personal-bank pay for every invoice. There is no bill row in this file.

expect(result).toEqual(linkedCreateAction.childReportID);
});

it('should return the childReportID for a bill with one expense', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one-expense test stops at the thread id. Nothing asserts that an approver or admin can edit category, tag, or billable on that bill expense.

@mananjadhav

Copy link
Copy Markdown
Collaborator

@cead22 Quick bump on the comments.

@trjExpensify

Copy link
Copy Markdown
Contributor

https://github.com/Expensify/Auth/pull/26177 is on prod, so I think the hold from the title can be removed unless it's outdated.

@cead22 cead22 closed this Dec 1, 2026
@mananjadhav

Copy link
Copy Markdown
Collaborator

@cead22 Is this PR not needed anymore?

@cead22

cead22 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Correct. I forgot you reviewed it so let me know what I need to do to compensate you for it

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants