Skip to content

Revert isPayer membership check to restore role-based payer check#93700

Merged
pecanoro merged 2 commits into
mainfrom
claude-revertIsPayerMembershipCheck
Jun 17, 2026
Merged

Revert isPayer membership check to restore role-based payer check#93700
pecanoro merged 2 commits into
mainfrom
claude-revertIsPayerMembershipCheck

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This reverts the isPayer change introduced in #81303, restoring the previous role-based payer check.

PR #81303 changed isPayer to additionally gate payer status on workspace membership via policy.employeeList. That approach is flaky because policy.employeeList can be loaded only partially from the backend and may not include the current user. When the current user is missing from policy.employeeList, isPayer incorrectly returns false, which in turn makes isExportAction return false and hides the Export to integration bulk action until the full employee list is loaded (for example, after opening a report).

PR #81303 was intended to $ #81096, but that issue can no longer be reproduced, so it is safe to revert and restore the previous role-based check.

Changes:

Fixed Issues

$ #92976 (comment)
PROPOSAL: #92976 (comment)

Tests

1. Verify the original bug from #81096 is NOT reintroduced (the reason #81303 was created):

Precondition: Admin invites a non-admin approver and a member to the workspace.

  1. [Member] Go to the workspace chat.
  2. [Member] Create an expense. Do not click Submit on the preview.
  3. [Non-admin approver] Open the member's workspace chat.
  4. [Non-admin approver] Leave the workspace.
  5. [Non-admin approver] Go to Home.
  6. Verify that "Pay 1 report" does NOT appear in the For you section after the approver leaves the workspace.

2. Verify the export bulk action appears without opening the report first (#92976):

Precondition: You have a workspace connected to an accounting integration (e.g., NetSuite), with reports in the approved/awaiting-export state.

  1. Clear cache and restart.
  2. Go to Spend > Reports (or Spend > Awaiting export).
  3. Bulk-select the approved reports.
  4. Verify both "Export to [integration]" and "Mark as manually exported" appear in the bulk-select menu immediately, without having to open a report first.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests.

QA Steps

Same as Tests above.

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • 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 followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • 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 a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
Screen.Recording.2026-06-17.at.10.02.49.PM.mov
Screen.Recording.2026-06-17.at.3.37.43.PM.mov
Screen.Recording.2026-06-17.at.3.32.00.PM.mov

Reverts the employeeList/membership-based gating added in #81303 so the
Export to integration action is no longer hidden when policy.employeeList
is only partially loaded.

Co-authored-by: ahmedGaber93 <ahmedGaber93@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

The only failing check is PR Author Checklist / checklist, and it fails for a reason I can't fix by pushing code:

##[error]PR Author Checklist is not completely filled out. Please check every box to verify you've thought about the item.

That check only passes once the author ticks every box in the ### PR Author Checklist section of the PR description. It's not a code defect.

Every automated check passes — typecheck, all 8 test jobs, knip, ESLint, Prettier, React Compiler, Storybook, and all builds. (baseline-perf-tests / branch-perf-tests are still-running benchmarks, not failures.)

To make checks green: complete the PR Author Checklist (and fill in/confirm the Tests, Offline tests, and QA Steps sections, or add [No QA] to the title if applicable). No code change is needed.

@ahmedGaber93

Copy link
Copy Markdown
Contributor

@MelvinBot Mark all author checklist as checked

@MelvinBot MelvinBot marked this pull request as ready for review June 17, 2026 13:13
@MelvinBot MelvinBot requested a review from a team as a code owner June 17, 2026 13:13
@melvin-bot melvin-bot Bot requested review from ahmedGaber93 and heyjennahay and removed request for a team June 17, 2026 13:13
@melvin-bot

melvin-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

@ahmedGaber93 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 removed the request for review from a team June 17, 2026 13:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9d3a49b80

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/ReportUtils.ts
}
}

const policy = reportPolicy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`] ?? null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore the workspace policy guard for payers

When a user leaves a workspace and the report's policy is no longer available locally, this now falls through instead of rejecting the workspace report. Because isMoneyRequestReport() also includes expense reports, the final manager check can still return true for an expense report whose managerID is the former user, and callers such as ReportPreviewActionUtils.canPay treat missing policy payments as enabled. In that leave-workspace/missing-policy state, the former approver can still see pay-related UI for workspace expenses, which is the regression the removed test covered.

Useful? React with 👍 / 👎.

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.

@MelvinBot add this condition here:

if no policy is found, let’s return early.

if (!policy && !isIOUReport(iouReport) && iouReport?.policyID && iouReport.policyID !== CONST.POLICY.ID_FAKE) {
    return false;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 24f26c3. Added the early return right after the policy resolution in isPayer:

if (!policy && !isIOUReport(iouReport) && iouReport?.policyID && iouReport.policyID !== CONST.POLICY.ID_FAKE) {
    return false;
}

This rejects workspace reports when the policy isn't available locally (e.g. after the user leaves the workspace), which also addresses the regression the codex bot flagged above.

Co-authored-by: ahmedGaber93 <ahmedGaber93@users.noreply.github.com>
@MelvinBot MelvinBot requested a review from a team as a code owner June 17, 2026 18:08
@melvin-bot melvin-bot Bot requested review from pecanoro and removed request for a team June 17, 2026 18:08
@melvin-bot

melvin-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

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

@ahmedGaber93

ahmedGaber93 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot Please add a complete author checklist from here, and mark all items as checked

@pecanoro

Copy link
Copy Markdown
Contributor

@ahmedGaber93 We are missing the videos/screenshots. Also, are the QA steps the same as the tests?

@ahmedGaber93

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 proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • 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 a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-06-17.at.3.32.00.PM.mov
Screen.Recording.2026-06-17.at.3.37.43.PM.mov
Screen.Recording.2026-06-17.at.10.02.49.PM.mov

@ahmedGaber93

Copy link
Copy Markdown
Contributor

@MelvinBot Please update offline steps to be

  1. Verify the original bug from #81096 is NOT reintroduced (the reason #81303 was created):

Precondition: Admin invites a non-admin approver and a member to the workspace.

Online steps

  1. [Member] Go to the workspace chat.
  2. [Member] Create an expense. Do not click Submit on the preview.
  3. [Non-admin approver] Open the member's workspace chat.

Offline steps

  1. [Non-admin approver] Leave the workspace.
  2. [Non-admin approver] Go to Home.
  3. Verify that "Pay 1 report" does NOT appear in the For you section after the approver leaves the workspace.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Updated the Offline tests section to split test 1 into Online steps (1–3) and Offline steps (4–6) as requested.

@ahmedGaber93

ahmedGaber93 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot update Screenshots/Videos on your author checklist to be

Screenshots/Videos

MacOS: Chrome / Safari
Screen.Recording.2026-06-17.at.10.02.49.PM.mov
Screen.Recording.2026-06-17.at.3.37.43.PM.mov
Screen.Recording.2026-06-17.at.3.32.00.PM.mov

@ahmedGaber93

Copy link
Copy Markdown
Contributor

@MelvinBot Could you check why author checklist failed

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The author checklist failed because not every checkbox in the PR description was ticked. From the failed run log:

You completed 25 out of 49 checklist items with 0 unfinished items

##[error]PR Author Checklist is not completely filled out. Please check every box to verify you've thought about the item.

The check counts all checkboxes in the PR template, not just the "PR Author Checklist" section — including the Verify that no errors appear in the JS console boxes in the Tests and QA Steps sections, which were still unchecked at the time.

Good news: this is already resolved. A newer run of the same check (run 27715348219, 19:47 UTC) ran after the failing one (19:20 UTC) and passed, so the remaining boxes were ticked in the meantime. No action needed.

@pecanoro

Copy link
Copy Markdown
Contributor

@MelvinBot Can you add the elements you remove from the PR Author Checklist section in the PR description?

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Done — I restored the full PR Author Checklist in the description. The previously-checked items keep their checked state; the restored items (the proper code patterns sub-items and the conditional If a new file/CSS/asset…, UI, Storybook, deeplink, etc. items) are left unchecked for the author to review and tick as applicable.

@pecanoro pecanoro merged commit 6ad9ea9 into main Jun 17, 2026
42 of 73 checks passed
@pecanoro pecanoro deleted the claude-revertIsPayerMembershipCheck branch June 17, 2026 20:14
Copilot stopped work on behalf of pecanoro due to an error June 17, 2026 20:15
Copilot AI requested a review from pecanoro June 17, 2026 20:15
@github-actions

Copy link
Copy Markdown
Contributor

🚧 @pecanoro 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.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/pecanoro in version: 9.4.15-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 No help site changes required.

I reviewed the changes in this PR against the help site files under App/docs/articles and no documentation updates are needed.

Why: This PR is a pure internal-logic revert. It restores the previous role-based isPayer check in src/libs/ReportUtils.ts (removing the employeeList/membership gating added by #81303) and removes the two associated unit tests. There are:

  • No new or changed user-facing features
  • No new or changed UI text, tab names, settings labels, or buttons
  • No change to documented product behavior

If anything, this restores the originally documented behavior — the Export to integration bulk action now appears as expected without needing to open a report first. Since the help site already reflects that intended behavior, there is nothing to update.

@ahmedGaber93, no help site PR was created since no docs changes are required. Please confirm you agree with this assessment — if you believe a docs update is needed, let me know what behavior changed and I'll create the draft PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.4.15-3 🚀

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

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.

4 participants