Skip to content

[Due for payment 2025-07-30] [$250] Reports - "Pay" button displayed on unapproved expense preview after changing workspace. #63291

Closed

Description

@mitarachim

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.56-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): ibellicotest+948@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 - Android 12 - Chrome
App Component: Search

Action Performed:

Prerequisite: User has at least two workspace created.
Prerequisite 2: Both workspaces has delayed submissions and approvals enabled.

  1. Open the Expensify app.
  2. Open any workspace chat.
  3. Submit a manual expense.
  4. Tap on "Submit" on expense preview.
  5. Navigate to "Workspaces" and delete the workspace where the expense was submitted.
  6. Navigate to "Reports"
  7. Open the just created expense.
  8. Tap on "More" and select "Change Workspace"
  9. Select another workspace and change the expense to it,
  10. Tap on the arrow on the top left corner to return to expenses list.
  11. Return to inbox.
  12. Navigate to "Reports" again.
  13. Note that a "Pay" button appeared on the expense preview, despite being unapproved.
  14. Open the expense.
  15. Note that an "Approve" button is displayed on top.

Expected Result:

"Approve" button should be displayed on the preview of an expense that is still unapproved.

Actual Result:

After changing an unapproved expense from a deleted workspace to a different one, a "Pay" button appears on preview on "Reports" despite the expense being still unapproved.

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

Bug6849190_1748908107788.Pay.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021929949845432749842
  • Upwork Job ID: 1929949845432749842
  • Last Price Increase: 2025-06-10
Issue OwnerCurrent Issue Owner: @lydiabarclay

Activity

  1. added
    Daily
    Bug
    on Jun 3, 2025
  2. melvin-bot commented on Jun 3, 2025

    @melvin-bot

    Triggered auto assignment to @lydiabarclay (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. bernhardoj commented on Jun 3, 2025

    @bernhardoj
    Contributor

    Proposal

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

    Pay button is displayed in reports page when the report is not approved yet.

    What is the root cause of that problem?

    The pay button shows when canIOUBePaid is true. We already check if the report should be approved first or not by using canApproveIOU.

    const shouldBeApproved = canApproveIOU(iouReport, policy, transactions);

    However, it returns false because the expense report is archived.

    const isArchivedExpenseReport = isArchivedReport(reportNameValuePairs);

    We don't optimistically unarchive the expense report when moving the report to another workspace, but BE also doesn't do that either, so it's maybe expected. canIOUBePaid actually also checks whether the report is archived or not, but it checks the chat report instead of the expense report, and it's not archived, so the pay button is shown.

    !isChatReportArchived &&

    Then, why the approve button show on the expense report page? It's because it uses the ReportPrimaryActionUtils and it doesn't check if the expense report is archived or not.

    function isApproveAction(report: Report, reportTransactions: Transaction[], policy?: Policy) {
    const currentUserAccountID = getCurrentUserAccountID();
    const managerID = report?.managerID ?? CONST.DEFAULT_NUMBER_ID;
    const isCurrentUserManager = managerID === currentUserAccountID;
    if (!isCurrentUserManager) {
    return false;
    }
    const isExpenseReport = isExpenseReportUtils(report);
    const isReportApprover = isApproverUtils(policy, currentUserAccountID);
    const isApprovalEnabled = policy?.approvalMode && policy.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL;
    if (!isExpenseReport || !isReportApprover || !isApprovalEnabled || reportTransactions.length === 0) {
    return false;
    }
    const isPreventSelfApprovalEnabled = policy?.preventSelfApproval;
    const isReportSubmitter = isCurrentUserSubmitter(report.reportID);
    if (isPreventSelfApprovalEnabled && isReportSubmitter) {
    return false;
    }
    const isOneExpenseReport = isExpenseReport && reportTransactions.length === 1;
    const isReportOnHold = reportTransactions.some(isOnHoldTransactionUtils);
    const isProcessingReport = isProcessingReportUtils(report);
    const isOneExpenseReportOnHold = isOneExpenseReport && isReportOnHold;
    if (isProcessingReport || isOneExpenseReportOnHold) {
    return true;
    }
    return false;
    }

    Only for pay button it checks whether the expense report is archived or not.

    if (isArchivedReport(reportNameValuePairs)) {
    return false;
    }

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

    Assuming it's the expected behavior that the expense report archived status is still true (if not, we need to unarchive it optimistically and on the BE), we first need to decide the approve and pay behavior, should we hide the approve and pay button when the expense report is archived?

    If yes, then

    1. We need to update canIOUBePaid so it checks for the expense report instead of the chat report

      const chatReportRNVP = data[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.chatReportID}`] ?? undefined;
      const canBePaid = canIOUBePaid(report, chatReport, policy, allReportTransactions, false, chatReportRNVP, invoiceReceiverPolicy);

      const reportNameValuePairs = chatReportRNVP ?? allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${chatReport?.reportID}`];

    2. Update ReportPrimaryActionUtils.isApproveAction (and ReportPreviewActionUtils) to return false if the expense report is archived, just like we did with ReportPrimaryActionUtils.isPrimaryPayAction.

    Else, we need to remove the archived check.

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

    N/A

  4. added
    External
    on Jun 3, 2025
  5. changed the title [-]Reports - "Pay" button displayed on unapproved expense preview after changing workspace.[/-] [+][$250] Reports - "Pay" button displayed on unapproved expense preview after changing workspace.[/+] on Jun 3, 2025
  6. melvin-bot commented on Jun 3, 2025

    @melvin-bot
  7. added
    Help Wanted
    on Jun 3, 2025
  8. melvin-bot commented on Jun 3, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)

  9. mananjadhav commented on Jun 7, 2025

    @mananjadhav
    Collaborator

    we first need to decide the approve and pay behavior, should we hide the approve and pay button when the expense report is archived

    @lydiabarclay Can you please confirm this?

  10. lydiabarclay commented on Jun 9, 2025

    @lydiabarclay
    Contributor

    @Expensify/design what do u think

  11. shawnborton commented on Jun 9, 2025

    @shawnborton
    Contributor

    I'm actually pretty lost on this one... @trjExpensify any ideas here?

    If you have an expense in the processing state, I didn't realize you could even delete the workspace to begin with?

  12. 49 remaining items

  13. lydiabarclay commented on Jul 30, 2025

    @lydiabarclay
    Contributor

    @mananjadhav can you advise, I am unclear whether this indicates a regression has occurred

  14. srikarparsi commented on Jul 31, 2025

    @srikarparsi
    Contributor

    I commented on the other issue, asking how it links back to this issue. I think we can wait on that response before issuing payment @lydiabarclay

  15. mananjadhav commented on Aug 1, 2025

    @mananjadhav
    Collaborator

    @lydiabarclay @srikarparsi I can confirm that the Approve button was visible when we did test the PR. Moreover this has been tested a few times considering having conflicts, and then retesting after BE change.

    This flow didn't work before as the workspace was archived and we are only updating the archived field here. The button after the fix was pushed (my video here and @bernhardoj's latest video here). Hence I feel the linked issue is not regression and should be treated separately.

  16. lydiabarclay commented on Aug 1, 2025

    @lydiabarclay
    Contributor

    Ok great, can you please fill out the bz checklist @mananjadhav ?

  17. lydiabarclay commented on Aug 1, 2025

    @lydiabarclay
    Contributor

    Payment Summary

    Contributor: @bernhardoj due $250 via NewDot
    Contributor+: @mananjadhav due $250 via NewDot

    ✅ Regression test filed

  18. mananjadhav commented on Aug 1, 2025

    @mananjadhav
    Collaborator

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: Long standing bug couldn't pinpoint an offending PR. Can also be treated as a feature request.

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: NA

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/532872

    Regression Test Proposal

    Precondition:

    • User has at least two workspace created.
    • Both workspaces has delayed submissions and approvals enabled.

    Test:

    1. Open the first workspace chat
    2. Submit a manual expense
    3. Press "Submit" on the expense preview
    4. Open "Workspaces" and delete the workspace where the expense was submitted
    5. Open "Reports"
    6. Open the just created expense
    7. Go offline
    8. Press "More" and select "Change Workspace"
    9. Select the 2nd workspace
    10. Verify the "Approve" button shows on the header
    11. Go back
    12. Open "Reports" again
    13. Verify that the "Approve" button appeared on the expense preview

    Do we agree 👍 or 👎

  19. mananjadhav commented on Aug 1, 2025

    @mananjadhav
    Collaborator

    I am also posting two scenarios here. The change we made was more of an unarchiving the workspace and unrelated to the primary actions. If it was an issue from this PR, then both the scenarios would've failed.

    Scenario 1: If you see Submit button shows up and then subsequent action of Approve shows just fine.

    submit-button-shows-up.mov

    Scenario 2: Approve button doesn't show up.

    approve-button-not-showing-up.mov
  20. lydiabarclay commented on Aug 4, 2025

    @lydiabarclay
    Contributor

    Payment summary here

  21. bernhardoj commented on Aug 5, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  22. flaviadefaria commented on Aug 6, 2025

    @flaviadefaria
    Contributor

    $250 Approved for @mananjadhav

  23. JmillsExpensify commented on Aug 20, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions