Skip to content

[Payment due @getusha] Fix invoice Pay actions with redacted sender policy data - #105553

Merged
iwiznia merged 3 commits into
mainfrom
codex/issue-697049-onyx-policy
Nov 10, 2026
Merged

iwiznia merged 3 commits into
mainfrom
codex/issue-697049-onyx-policy

Conversation

@Beamanator

@Beamanator Beamanator commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Auth's policy redaction leaves invoice viewers with only the sender policy's public identity. Invoice Pay and Pay Elsewhere must depend on the invoice and receiver authorization, even when the sender policy uses reimburseNo or has no reimbursement setting in Onyx. This moves the invoice branch ahead of the sender reimbursement gate and adds regression tests for payment eligibility and the exact Onyx update methods Auth uses to replace previously cached full policy data. The companion Auth change is https://github.com/Expensify/Auth/pull/26135. This App change is intended to merge first so clients can handle redacted sender policies before Auth deploys.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/697049
PROPOSAL: https://github.com/Expensify/Expensify/issues/697049#issuecomment-6509455554

Tests

  1. Run npm test -- --runInBand tests/unit/Search/NonmemberPolicyRedactionTest.ts tests/actions/IOUTest/ReportWorkflowTest.ts. Result: 113 passed. The tests apply Auth's first-page SET, later-page MERGE, SearchForTodos MERGE_COLLECTION, and policy SET to a cached full policy with synthetic credentials, bank and employee fields; they inspect both final top-level and snapshot state, including mileage rate lookup.
    Before-and-after check: the new invoice test failed against the original ReportUtils.ts from base commit 40f7032 (Pay returned false for a reimburseNo sender policy), then passed with this PR restored.
  2. Run npm run typecheck and scoped bun scripts/lint/index.ts on the three changed files. Both passed.
  3. Run rendered report UI suites MoneyRequestViewReportFieldsTest.tsx and MoneyReportViewTest.tsx: 48 passed.
  4. In the local VM with this App head (32cb235) and the companion Auth head (https://github.com/Expensify/Auth/commit/025f3c44f5ae0f72fb600ba6f37a584d4fb28087), create a synthetic business invoice from a sender workspace using reimburseNo to a receiver workspace. As receiver admin in macOS Chrome, open the invoice, verify Pay and Mark as paid (Pay Elsewhere), reload, and verify the options persist. This passed; a $1.00 synthetic invoice was marked paid locally and a $1.02 invoice was left outstanding. No real funds moved.
  5. As a receiver workspace user, open the invoice and verify Pay is absent. This passed for the sender account with receiver user role. A separate receiver user was denied invoice access, so an independent accessible nonadmin detail page remains unverified.
  6. Inspect the live nonmember SearchForTodos response and final Onyx policy after a reload, including a cached policy seeded with synthetic private fields. The response contained only public identity fields and null clears; the final Onyx policy retained only avatarURL, id, name, role, and type. Pay remained available to the authorized receiver admin.
  7. Local companion Auth tests: SearchForTodos 12/12 and SearchUtils 61/61 passed; Search2 67/68 passed, with an unrelated local testTripRooms 500 payload parse failure after the new redaction test passed. Current-head Auth CI Auth Tests passed.
  8. Remaining manual coverage: invoice Search page two, an accessible shared expense with tags/time/mileage, high-traffic staging/production, and all native/mobile platforms.
  • Verify that no errors appear in the JS console during manual UI verification. Local Chrome QA captured React DOM/style/nested-button hydration errors and failed external-resource DNS requests; there were no pageerror events. Their relationship to this PR has not been established, and a clean-console result has not been established.

Offline tests

  1. Open the outstanding synthetic business invoice as receiver admin while online. Disconnect the local browser, confirm navigator.onLine === false and the app's offline cue, and verify cached Pay and Mark as paid remain visible. Reconnect and reload; verify Pay remains visible. Completed in macOS Chrome with this App PR and the companion Auth head. No offline payment write was attempted.

QA Steps

Prerequisites: Use staging with both this App change and the companion Auth change. Prepare two test workspaces: A sends invoices and B receives them. B’s admin needs a connected USD business bank account.

  1. As A’s admin, go to Workspaces → A → More features and turn on Invoices. Go to Workflows → Payments and turn off the Payments switch.
  2. As B’s admin, go to Account → Troubleshoot → Beta overrides, select View, and turn on payInvoiceViaExpensify.
  3. As A’s admin, click + → Send invoice. Select A in Send from, address a small USD invoice to B’s admin, and send it.
  4. As B’s admin, open the invoice conversation in Inbox and click View on the invoice card. Open Pay [amount] → Pay [amount] as a business → Mark as paid. This establishes B as the business receiver for the next invoice.
  5. As A’s admin, return to that conversation and use + → Send invoice to send a second invoice. Leave this one unpaid.
  6. As B’s admin, click View on the unpaid invoice. Open Pay [amount] and confirm the menu contains B’s business bank account and Mark as paid. Refresh, then check the same menu again. Do not pay the second invoice.
  7. In B, use Members → Invite member to add A’s sender account with the Member role. Sign in as that sender, open the unpaid invoice with View, and confirm there is no payment action.
  • Verify that no errors appear in the JS console. See the local Chrome console note in Tests.

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) (N/A: no app copy added.)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers (N/A: no new code pattern added.)
  • 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) (Rendered report UI suites: 48 passed.)
  • If new assets were added or existing ones were modified, I verified that: (N/A: no assets changed.)
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg) (N/A: no assets changed.)
    • The assets load correctly across all supported platforms. (N/A: no assets changed.)
  • 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. (N/A: no message editing or sending code changed.)
  • 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) (N/A: no generic component changed.)
  • 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. (N/A: no Storybook component changed.)
  • 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. (N/A: no component or page route changed; the shared payment utility was tested on a logged-in invoice deeplink.)
  • 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. (N/A: no main merge commit in this PR.)

Screenshots/Videos

Android: Native

Not captured; this platform has not been manually tested with the companion Auth change.

Android: mWeb Chrome

Not captured; this platform has not been manually tested with the companion Auth change.

iOS: Native

Not captured; this platform has not been manually tested with the companion Auth change.

iOS: mWeb Safari

Not captured; this platform has not been manually tested with the companion Auth change.

MacOS: Chrome / Safari

Local macOS Chrome screenshots were captured for the combined App+Auth business-invoice flow, Pay action, Mark as paid menu, nonadmin view, offline view, and final Onyx state. They are saved in the local QA evidence bundle and are not attached to this PR. Safari remains untested.

🤖 Posted by Codex, an AI coding agent acting for @Beamanator.

@Beamanator
Beamanator marked this pull request as ready for review November 1, 2026 16:12
@Beamanator
Beamanator requested review from a team as code owners November 1, 2026 16:12
@Beamanator

Copy link
Copy Markdown
Contributor Author

@codex review

@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and eh2077 and removed request for a team November 1, 2026 16:13
@melvin-bot

melvin-bot Bot commented Nov 1, 2026

Copy link
Copy Markdown

@eh2077 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]

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-11-01T16:52:19.184688Z 32cb235 Manual request
ℹ️ 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.

Comment thread src/libs/ReportUtils.ts Resolved
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor Author

@codex review

The three review findings on the previous head were addressed in commit 32cb23536a6c88425da1cd5a36662f4823e61e77. Please review the updated head.

🤖 Posted by Codex, an AI coding agent acting for @Beamanator.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 32cb23536a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@JmillsExpensify JmillsExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@eh2077

eh2077 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@Beamanator I'm ooo, could you help assign another C+ to review this PR please?

@Beamanator
Beamanator requested review from a team and removed request for eh2077 November 5, 2026 16:53
@melvin-bot
melvin-bot Bot requested review from getusha and removed request for a team November 5, 2026 16:53
@melvin-bot

melvin-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

@getusha 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]

@Beamanator

Copy link
Copy Markdown
Contributor Author

Sounds good! can you help review here please @getusha ?

@Beamanator

Copy link
Copy Markdown
Contributor Author

bump @getusha if you're not free, please let me know so i can find another reviewer 🙏

@getusha

getusha commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Sorry, will review today

@Beamanator

Copy link
Copy Markdown
Contributor Author

no worries! thanks so much!

@getusha

getusha commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Setup

  1. Workspace A (sender): turn on Invoices, then turn off Payments in Workflows.
  2. From A, send an invoice to workspace B’s admin. As B’s admin, pay it as a business with workspace B.
  3. From A, send a second invoice into that room and leave it unpaid.
  4. As B’s admin, turn on the payInvoiceViaExpensify beta in Troubleshoot > Beta overrides. Use USD.

Test

  1. As B’s admin, open the unpaid invoice. You should see Pay and Mark as paid. On main, only Mark as paid shows.
  2. Add the sender’s account to B as a regular member (“user” role). As the sender, open the invoice. Verify that No Pay should show.

@MelvinBot is this QA steps accurate drived from the PR tests

@MelvinBot

Copy link
Copy Markdown
Contributor

Yes—for the invoice-payment regression, your steps match the PR tests, with these clarifications:

  • Receiver admin: The test expects both Pay and Pay Elsewhere for an unpaid business invoice when A has reimburseNo or only public policy data. Your “Pay and Mark as paid” expectation matches that intent. Test assertions.
  • Receiver regular member: Your sender-as-B-member scenario is valid. Strengthen the expectation to neither Pay nor Mark as paid: business-invoice payment eligibility requires B’s admin role, regardless of whether the viewer administers A. Authorization check.
  • First invoice: Paying it as business B is setup to establish the business receiver; the second invoice must remain unpaid. The automated test starts with an already-converted business invoice room.
  • Beta + USD: Appropriate for exposing Expensify payment methods, but these are UI prerequisites—not conditions exercised by the new unit test. Payment-option gating.

These steps cover the payment fix, not the full PR QA: policy redaction/cache clearing, search pagination, and shared-expense rendering still need separate coverage.

This is a code/test comparison, not a fresh browser verification; I haven’t independently confirmed the “on main” observation.


view run

@getusha

getusha commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • 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 verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp

admin side:

Screenshot_1793987115
Android: mWeb Chrome Screenshot_1793986106
iOS: HybridApp

Build issues

iOS: mWeb Safari Screenshot iPhone 17 Pro 06-11-2026 at 8 27 29 PM
MacOS: Chrome / Safari Screenshot 2026-11-06 at 8 18 20 PM

@getusha

getusha commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

@Beamanator we need to update QA steps it can be confusing 🙏

@getusha getusha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

@melvin-bot
melvin-bot Bot requested a review from iwiznia November 6, 2026 18:36
@melvin-bot

melvin-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

@iwiznia 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]

@melvin-bot melvin-bot Bot changed the title Fix invoice Pay actions with redacted sender policy data [Payment due @getusha] Fix invoice Pay actions with redacted sender policy data Nov 6, 2026
@melvin-bot

melvin-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

🎯 @getusha, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/697049.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

@Beamanator

Copy link
Copy Markdown
Contributor Author

updated! all you @iwiznia 🙏

@iwiznia
iwiznia merged commit fb9b784 into main Nov 10, 2026
47 checks passed
@iwiznia
iwiznia deleted the codex/issue-697049-onyx-policy branch November 10, 2026 13:08
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/iwiznia in version: 9.5.36-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No FullStory changes needed. This PR only fixes eligibility for existing invoice Pay and Pay Elsewhere actions when sender policy data is redacted or reimbursements are disabled, and adds regression tests.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR fixes existing invoice payment eligibility without adding a new workflow, removing a beta, or making existing article instructions incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.36-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@melvin-bot

melvin-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #106680

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.

7 participants