Skip to content

[$250] Approve button not displayed in the bulk action menu #67416

Closed

Description

@m-natarajan

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.1.87-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @trjExpensify
Slack conversation (hyperlinked to channel name): #Migrate

Action Performed:

  1. Create two expenses with violations
  2. Go to Reports > Reports
  3. Bulk select the report > click X selected bulk action button
  4. Observe no Approve button in the bulk select menu

Expected Result:

Approve should be shown in the bulk action menu.

Actual Result:

Approve not displayed in the bulk action menu.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
2025-07-30_13-56-40.mp4
Recording.1467.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021952767190990111694
  • Upwork Job ID: 1952767190990111694
  • Last Price Increase: 2025-08-05
Issue OwnerCurrent Issue Owner: @greg-schroeder

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 30, 2025
  2. melvin-bot commented on Jul 30, 2025

    @melvin-bot

    Triggered auto assignment to @greg-schroeder (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. abzokhattab commented on Jul 30, 2025

    @abzokhattab
    Contributor

    Proposal

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

    Approve button not displayed in the bulk action menu

    What is the root cause of that problem?

    In the violation‑handling block of getAction, we check for violations and return (VIEW or REVIEW) without ever checking if the user can approve. As a result, approval logic is never reached for reports with violations.

    if ((isSubmitter || isApprover || isAdmin) && hasAnyViolations(report.reportID, allViolations, allReportTransactions)) {
    if (isSubmitter && !isApprover && !isAdmin && !canReview(report, allViolations, isIOUReportArchived || isChatReportArchived, policy, allReportTransactions)) {
    return CONST.SEARCH.ACTION_TYPES.VIEW;
    }
    return CONST.SEARCH.ACTION_TYPES.REVIEW;
    }
    // Submit/Approve/Pay can only be taken on transactions if the transaction is the only one on the report, otherwise `View` is the only option.

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

    we should add a condition for the approve, final conditions should be:

        if ((isSubmitter || isApprover || isAdmin) && hasAnyViolations(report.reportID, allViolations, allReportTransactions)) {
            if (canApproveIOU(report, policy, allReportTransactions) && isAllowedToApproveExpenseReportUtils(report, undefined, policy)) // optionally we can also check for "&& !hasOnlyPendingCardOrScanningTransactions && !hasOnlyHeldExpenses(report.reportID, allReportTransactions)"
    {
    
    
                return CONST.SEARCH.ACTION_TYPES.APPROVE;
            }
            if (isSubmitter && !isApprover && !isAdmin && !canReview(report, allViolations, isIOUReportArchived || isChatReportArchived, policy, allReportTransactions)) {
                return CONST.SEARCH.ACTION_TYPES.VIEW;
            }
            return CONST.SEARCH.ACTION_TYPES.REVIEW;
        }

    result:

    Image

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    we should add a test case that covers the case where there are violations and the user is not able to approve in the SearchUIUtilsTest file

    What alternative solutions did you explore? (Optional)

    NA

  4. lorretheboy commented on Jul 30, 2025

    @lorretheboy
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-08-06 11:17:24 UTC.

    Proposal

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

    Approve button not displayed in the bulk action menu

    What is the root cause of that problem?

    Reports with violations were not showing the "Approve" action in bulk select menus because the canApproveIOU function used in SearchUIUtils.ts doesn't handle violations properly which returning VIEW/REVIEW for reports with violations

    return CONST.SEARCH.ACTION_TYPES.VIEW;

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

    Add reportAction property to TransactionListItemType that represents the action that can be taken at the report level

                reportAction: report ? getAction(data, allViolations, `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, currentSearch) : CONST.SEARCH.ACTION_TYPES.VIEW,

    const transactionSection: TransactionListItemType = {
    action: getAction(data, allViolations, key, currentSearch),
    report,

    Add an additional check in the getAction function in SearchUIUtils.ts that allows approval for expense reports that are processing if the user has appropriate approval permissions. By using this ways, it catches all processing reports that should be approvable, not just those with violations

    We need to support one more param in getAction function to distinguish bulk selection or not isForBulkSelection = false

    Add here

            // For individual transactions with violations, always show Review
            if (isTransaction) {
                return CONST.SEARCH.ACTION_TYPES.REVIEW;
            }
    
            // For reports with violations, check if user can approve the report
            const isAllowedToApproveExpenseReport = isAllowedToApproveExpenseReportUtils(report, undefined, policy);
            const hasOnlyPendingCardOrScanningTransactions = allReportTransactions.length > 0 && allReportTransactions.every(isPendingCardOrScanningTransaction);
    
            if (
                canApproveIOU(report, policy, allReportTransactions) &&
                isAllowedToApproveExpenseReport &&
                !hasOnlyPendingCardOrScanningTransactions &&
                !hasOnlyHeldExpenses(report.reportID, allReportTransactions)
            ) {
                return CONST.SEARCH.ACTION_TYPES.APPROVE;
            }

    Updated SearchContext.tsx to use reportAction instead of action when creating selectedReports from individual transactions

    .map(({reportID, reportAction = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action: reportAction, total, policyID}));

    .map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));

    .map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));

    .map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, amount: total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));

    Image

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Update and add new test cases in SearchUIUtilsTest.ts

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  5. bernhardoj commented on Jul 30, 2025

    @bernhardoj
    Contributor

    Proposal

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

    Approve doesn't show in bulk action.

    What is the root cause of that problem?

    The approve (or pay) option shows if all the selected report action is approve.

    const shouldShowApproveOption =
    !isOffline &&
    !isAnyTransactionOnHold &&
    (selectedReports.length
    ? selectedReports.every((report) => report.action === CONST.SEARCH.ACTION_TYPES.APPROVE)
    : selectedTransactionsKeys.every((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.APPROVE));

    But in our case, the action is Review because it has violations.

    if ((isSubmitter || isApprover || isAdmin) && hasAnyViolations(report.reportID, allViolations, allReportTransactions)) {
    if (isSubmitter && !isApprover && !isAdmin && !canReview(report, allViolations, isIOUReportArchived || isChatReportArchived, policy, allReportTransactions)) {
    return CONST.SEARCH.ACTION_TYPES.VIEW;
    }
    return CONST.SEARCH.ACTION_TYPES.REVIEW;
    }

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

    We can update getAction to return an array of actions. For cases, that only allows 1 action, we will still return early, for example

    if (currentSearch === CONST.SEARCH.SEARCH_KEYS.EXPORT) {
    return CONST.SEARCH.ACTION_TYPES.EXPORT_TO_ACCOUNTING;
    }
    if (!isTransaction && !isReportEntry(key)) {
    return CONST.SEARCH.ACTION_TYPES.VIEW;
    }

    if (currentSearch === CONST.SEARCH.SEARCH_KEYS.EXPORT) {
        return [CONST.SEARCH.ACTION_TYPES.EXPORT_TO_ACCOUNTING];
    }
    
    if (!isTransaction && !isReportEntry(key)) {
        return [CONST.SEARCH.ACTION_TYPES.VIEW];
    }

    Then, we will have a local allActions variable.

    const allActions: SearchTransactionAction[] = [];

    If there is violation, we add the action to the array.

    if ((isSubmitter || isApprover || isAdmin) && hasAnyViolations(report.reportID, allViolations, allReportTransactions)) {
        if (isSubmitter && !isApprover && !isAdmin && !canReview(report, allViolations, isIOUReportArchived || isChatReportArchived, policy, allReportTransactions)) {
            allActions.push(CONST.SEARCH.ACTION_TYPES.VIEW);
        } else {
            allActions.push(CONST.SEARCH.ACTION_TYPES.REVIEW);
        }
    }

    If approve (or pay/submit) is available, we push it too.

    if (
        canApproveIOU(report, policy, allReportTransactions) &&
        isAllowedToApproveExpenseReport &&
        !hasOnlyPendingCardOrScanningTransactions &&
        !hasOnlyHeldExpenses(report.reportID, allReportTransactions)
    ) {
        allActions.push(CONST.SEARCH.ACTION_TYPES.APPROVE);
    }

    Then return the array.

    return allActions.length > 0 ? allActions : [CONST.SEARCH.ACTION_TYPES.VIEW];

    Next, add the new array to the report map. We get the first item and set it as the "main" action.

    App/src/libs/SearchUIUtils.ts

    Lines 1159 to 1161 in 101e0c1

    reportIDToTransactions[reportKey] = {
    ...reportItem,
    action: getAction(data, allViolations, key, currentSearch, actions),

    const allActions = getAction(data, allViolations, key, currentSearch, actions);
    reportIDToTransactions[reportKey] = {
        ...reportItem,
        action: allActions.at(0),
        allActions,

    Next, in SearchContext, we need to map the allActions too.

    if (data.length && data.every(isTransactionReportGroupListItemType)) {
    selectedReports = data
    .filter((item) => isMoneyRequestReport(item) && item.transactions.every(({keyForList}) => selectedTransactions[keyForList]?.isSelected))
    .map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, total = CONST.DEFAULT_NUMBER_ID, policyID}) => ({reportID, action, total, policyID}));
    }

    .map(({reportID, action = CONST.SEARCH.ACTION_TYPES.VIEW, total = CONST.DEFAULT_NUMBER_ID, policyID, allActions = [action]}) => ({reportID, action, total, policyID, allActions}));

    Last, instead of checking the main action, we can check if allActions includes the approve action (or pay or submit)

    const shouldShowApproveOption =
    !isOffline &&
    !isAnyTransactionOnHold &&
    (selectedReports.length
    ? selectedReports.every((report) => report.action === CONST.SEARCH.ACTION_TYPES.APPROVE)
    : selectedTransactionsKeys.every((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.APPROVE));

    ? selectedReports.every((report) => report.allActions.includes(CONST.SEARCH.ACTION_TYPES.APPROVE))

    we can use Set instead of Array

    (We need the fix from #66993 too)

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    First, we need to update the getAction test because it now returns an array. Next, we can add a new case where the item can have Review and Approve actions.

  6. moved this to Second Cohort - HIGH in [#whatsnext] #migrateon Aug 4, 2025
  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 5, 2025
  8. melvin-bot commented on Aug 5, 2025

    @melvin-bot
  9. changed the title [-]Approve button not displayed in the bulk action menu[/-] [+][$250] Approve button not displayed in the bulk action menu[/+] on Aug 5, 2025
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 5, 2025
  11. 28 remaining items

  12. bernhardoj commented on Aug 21, 2025

    @bernhardoj
    Contributor

    Oh, I see. I just rechecked my PR, and it doesn't show the Approve for expenses (not the full report).

    web.mp4
  13. melvin-bot commented on Sep 15, 2025

    @melvin-bot

    This issue has not been updated in over 15 days. @greg-schroeder, @thienlnam, @bernhardoj, @dukenv0307 eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  14. dukenv0307 commented on Sep 22, 2025

    @dukenv0307
    Contributor

    @greg-schroeder The PR was merged so long ago. Can you please process the payment? Thanks

  15. dukenv0307 commented on Sep 24, 2025

    @dukenv0307
    Contributor

    Kindly bump @greg-schroeder

  16. greg-schroeder commented on Sep 26, 2025

    @greg-schroeder
    Contributor

    processing

  17. greg-schroeder commented on Sep 26, 2025

    @greg-schroeder
    Contributor

    Payment automation failed. Both contributors should be eligible for ND payments

  18. greg-schroeder commented on Sep 26, 2025

    @greg-schroeder
    Contributor

    Payment summary:

    C: @bernhardoj - $250 - ND manual request
    C+: @dukenv0307 - $250 - ND manual request

    Approved ☝️

  19. bernhardoj commented on Sep 27, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  20. quinthar commented on Oct 12, 2025

    @quinthar
    Contributor

    Approved $250 to @dukenv0307

  21. quinthar commented on Oct 12, 2025

    @quinthar
    Contributor

    Approved $250 to @bernhardoj

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorMonthlyKSv2ReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions