Skip to content

Expense - Approve button is not hidden or disabled when "Prevent self-approvals" is enabled #77367

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.2.75-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #76887
Email or phone of affected tester (no customers): sjdoinjsdoisjdois@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Critical User Impact
Device used: Mac 26.1 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • User has invited a member to the workspace.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create an expense.
  4. Open the expense report.
  5. Click Submit.
  6. Click More > Change approver.
  7. Click Add approver > Select the invited member > Save.
  8. Click More > Bypass approver > Change approver.
  9. Go to workspace settings > Workflows.
  10. Enable Prevent self-approvals.
  11. Go back to the expense report.
  12. Click Approve.

Expected Result:

Approve button should be hidden or disabled because "Prevent self-approvals" is enabled.

Actual Result:

Approve button is not hidden after bypassing approver and enabling "Prevent self-approvals", which leads to error when clicked.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 11, 2025
  2. melvin-bot commented on Dec 11, 2025

    @melvin-bot

    Triggered auto assignment to @twisterdotcom (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. github-actions commented on Dec 11, 2025

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  4. melvin-bot commented on Dec 11, 2025

    @melvin-bot

    Triggered auto assignment to @aldo-expensify (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  5. melvin-bot commented on Dec 11, 2025

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  6. Nodebrute commented on Dec 11, 2025

    @Nodebrute
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Approve button is not hidden or disabled when "Prevent self-approvals" is enabled

    What is the root cause of that problem?

    This is happening because in isApproveAction() function which controls the primary Approve button was missing the preventSelfApproval check.

    function isApproveAction(report: Report, reportTransactions: Transaction[], policy?: Policy) {
    const isAnyReceiptBeingScanned = reportTransactions?.some((transaction) => isScanning(transaction));
    if (isAnyReceiptBeingScanned) {
    return false;
    }
    const currentUserAccountID = getCurrentUserAccountID();
    const managerID = report?.managerID ?? CONST.DEFAULT_NUMBER_ID;
    const isCurrentUserManager = managerID === currentUserAccountID;
    if (!isCurrentUserManager) {
    return false;
    }
    const isExpenseReport = isExpenseReportUtils(report);
    const isApprovalEnabled = policy?.approvalMode && policy.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL;
    if (!isExpenseReport || !isApprovalEnabled || reportTransactions.length === 0) {
    return false;
    }
    if (reportTransactions.length > 0 && reportTransactions.every((transaction) => isPending(transaction))) {
    return false;
    }
    return isProcessingReportUtils(report);
    }

    • The isApproveAction() button only checks for ✅
    • If the user is the manager (managerID === currentUserAccountID)✅
    • If it's an expense report✅
    • If approval is enabled✅
    • If the report is processing✅
    • It did not check preventSelfApproval❌

    This makes it also inconsistent with other approving functions like ReportSecondaryActionUtils.isApproveAction() and ReportPreviewActionUtils.canApprove()

    What changes do you think we should make in order to solve the problem?

    We should add a check if self approval is enabled . We can do something like this here

      const isPreventSelfApprovalEnabled = policy?.preventSelfApproval;
        const isReportSubmitter = isCurrentUserSubmitter(report);
    
        if (isPreventSelfApprovalEnabled && isReportSubmitter) {
            return false;
        }
    
    

    This is the same approach we use here and here

    What alternative solutions did you explore? (Optional)

  7. m-natarajan commented on Dec 11, 2025

    @m-natarajan

    Not Repro, Windows 10/ Chrome, v9.2.75-3. Build not ready for native devices.

    Repro.-.issue.77367.-.Not.Repro.mp4
  8. yuwenmemon commented on Dec 11, 2025

    @yuwenmemon
    Contributor

    Thanks!

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringHourlyKSv2ReviewingHas a PR in review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions