Skip to content

bring back byass approver for manager - #98717

Open
hungvu193 wants to merge 5 commits into
Expensify:mainfrom
hungvu193:hans-enable-bypass-approver-for-manager
Open

bring back byass approver for manager#98717
hungvu193 wants to merge 5 commits into
Expensify:mainfrom
hungvu193:hans-enable-bypass-approver-for-manager

Conversation

@hungvu193

@hungvu193 hungvu193 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Bring back the By pass approver option for the manager. When manager choose by pass option, we will approve the money request

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/671638
PROPOSAL: N/A

Tests

Same as QA steps

  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."
Prerequisite: You're the manager of the report (or you're the approver and admin)

  1. Go to that report that you're manager > More > Change approver
  2. Verify that the Bypass approver is visible
  3. Choose that option and save
  4. Verify that the report is approved.
  • 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 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 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)
  • 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)
  • 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.
  • 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
Screen.Recording.2026-08-18.at.10.23.41.mov
iOS: mWeb Safari
Screen.Recording.2026-08-18.at.10.18.12.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-18.at.10.01.35.mov

@codecov

codecov Bot commented Aug 15, 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/pages/DynamicReportChangeApproverPage.tsx 1.53% <0.00%> (-0.16%) ⬇️
src/pages/Search/SearchChangeApproverPage.tsx 6.36% <0.00%> (-0.37%) ⬇️
... and 15 files with indirect coverage changes

@hungvu193

Copy link
Copy Markdown
Contributor Author

PR is ready. I'll upload the screenshots tomorrow. github is down....

@hungvu193
hungvu193 marked this pull request as ready for review August 18, 2026 02:50
@hungvu193
hungvu193 requested review from a team as code owners August 18, 2026 02:50
@melvin-bot
melvin-bot Bot requested a review from bernhardoj August 18, 2026 02:50
@melvin-bot

melvin-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

@bernhardoj 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 requested review from trjExpensify and removed request for a team August 18, 2026 02:50
Comment thread src/pages/Search/SearchChangeApproverPage.tsx
Comment thread src/pages/Search/SearchChangeApproverPage.tsx

@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: 4b87753462

ℹ️ 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/pages/DynamicReportChangeApproverPage.tsx
Comment thread src/pages/Search/SearchChangeApproverPage.tsx
@MelvinBot

Copy link
Copy Markdown
Contributor

Short answer: it won't map cleanly here, because this page is a bulk flow while the hook is scoped to a single report.

useConfirmApproval(reportID, …) binds to one report — it reads that one report's policy/transactions/violations, computes isAnyTransactionOnHold for it, and calls openHoldMenu from the MoneyReportHeaderModals context. SearchChangeApproverPage instead loops over selectedReports and approves each one (SearchChangeApproverPage.tsx:187-228). So:

  • Wrapping the page in one MoneyReportHeaderModals only provides context for a single reportID, not each selected report.
  • You can't call useConfirmApproval per report inside the loop — that breaks the rules of hooks.
  • The hold-menu branch (openHoldMenu) doesn't really translate to bulk approval anyway; you can't prompt a per-report hold decision mid-loop.

That's why the DynamicReportChangeApproverPage (single report) could reuse the hook via the provider, but this page calls approveMoneyRequest directly.

If the goal is to cut the duplicated arg-assembly, a better fit than the hook/provider would be extracting a small plain helper (e.g. buildApproveMoneyRequestParams(report, policy, …)) that both the hook and this loop call — that dedupes the payload construction without forcing single-report context onto a bulk page. Happy to do that if you'd like it.

}

if (isDelegateAccessRestricted) {
showDelegateNoAccessModal();

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.

We check for delegate access here, but we don't do the same in DynamicReportChangeApproverPage

@bernhardoj bernhardoj Aug 18, 2026

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.

Just done reading through the AI reviews, this is the same as #98717 (comment). Is it really out of scope? This PR adds the delegate access check before reassigning and approving the report.

Before this PR: bypass approver only reassigns the approver; no delegate access check. This means a delegate can reassign the approver, bulk or individual.
After this PR: bypass approver also approves the report when the current user is the manager. Bulk bypass approver on the search page is totally prevented for a delegate, while individual bypass approver allows delegate to reassign the approver, but not approving the report.

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.

I'm thinking about removing this check because we don't have this before 🤔 Wdyt

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.

If we remove the delegate check (so it works like before), we are still left with confirmApproval which prevents approving as a delegate and shows the restricted access modal.

I think it would be weird if we also show the restricted access modal when doing bulk approval before approveMoneyRequest because there would be n calls to the showDelegateNoAccessModal function. Wdyt of just returning early? So, bypass approver will

  1. reassign the approver (allowed for delegate)
  2. approve (not allowed for delegate; return early; nothing happens; approver is successfully reassigned in step 1, so when the user presses Approve manually, they will see the restricted modal)

But this means we need to customize useConfirmApproval for this case (bypass approver).

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.

yeah, I think that works, early return is better since we shouldn't show delegate modal inside the bulk actions

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.

Updated. Can you check?

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.

image

That works fine, but I think it's a little bit weird that I can bypass the approver by reassigning the approver to me multiple times. If that's expected or out of scope, then we are good.

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.

Cc @trjExpensify , should we drop assigning approver in this case?

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.

3 participants