Skip to content

[Due for payment 2025-03-13] [$250] Unapprove button is showing instead of Cancel payment button on reports queued for ACH reimbursement (and incorrect sys message when actioned on from OldDot) #56989

Closed

Description

@trjExpensify

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: v9.0.99-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: None
Email or phone of affected tester (no customers): tom+vbbaod2nd@trj.chat
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL: None
Issue reported by: @trjExpensify
Slack conversation (hyperlinked to channel name): None, found when I was testing something else.

Action Performed:

Prerequisites:

  • USD workspace with ACH reimbursement enabled
  • Admin is the workspace's payer, add one more normal member to the workspace.
  • Both payer and submitter haven't added a personal bank account yet.
  1. As the payer, create an expense > submit it to the workspace
  2. Approve it
  3. Click "Pay with Expensify"
  4. Click the report header
  5. Observe there's no "Cancel payment" button and the Unapprove button shows.
  6. Go to OldDot (use Settings > Domains as a shortcut) > Reports > click into the report
  7. Observe there's no Unapprove button showing on the report in OldDot
  8. Click "Cancel reimbursement" on the top of the report
  9. Switch back to NewDot > refresh
  10. Observe the incorrect canceledRequest system message is added to the report: canceled the $0.00 payment, because tom+vbbaod2nd@trj.chat did not enable their Expensify Wallet within 30 days
  11. As the normal member submitter on the workspace, create an expense and submit it.
  12. As the payer, repeat steps 2-10 and observe the same outcomes.

Expected Result:

  • The Cancel payment button should be shown to the workspace's payer up until the ACH cut off time for the day (@Gonals that logic for the cut off should be derived from the BE already I take it?)
  • The Unapprove button shouldn't show on a report that is queued for reimbursement via ACH (as the payment hasn't been canceled yet).
  • The adminCanceledRequest system message should be shown when canceling payments on a workspace.

Actual Result:

  • No Cancel Payment button in the report details screen.
  • Unapprove button incorrectly shows on a report that's queued to be reimbursed via ACH.
  • Incorrect system message is added to the report after taking the action in OldDot.

Workaround:

You can use OldDot to action on canceling the payment at least.

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

2025-02-18_01-54-48.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021891677107780037168
  • Upwork Job ID: 1891677107780037168
  • Last Price Increase: 2025-02-25
Issue OwnerCurrent Issue Owner: @trjExpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 18, 2025
  2. self-assigned this
    on Feb 18, 2025
  3. melvin-bot commented on Feb 18, 2025

    @melvin-bot
  4. changed the title [-]Unapprove button is showing instead of Cancel payment button on reports queued for ACH reimbursement (and incorrect sys message when actioned on from OldDot)[/-] [+][$250] Unapprove button is showing instead of Cancel payment button on reports queued for ACH reimbursement (and incorrect sys message when actioned on from OldDot)[/+] on Feb 18, 2025
  5. melvin-bot commented on Feb 18, 2025

    @melvin-bot

    Current assignee @trjExpensify is eligible for the Bug assigner, not assigning anyone new.

  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 18, 2025
  7. melvin-bot commented on Feb 18, 2025

    @melvin-bot

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

  8. trjExpensify commented on Feb 18, 2025

    @trjExpensify
    ContributorAuthor

    CC'ing @Gonals for vis here, as I believe you worked on the initial implementation of Cancel payment ~1 year ago. This has regressed pretty badly it seems.

  9. NJ-2020 commented on Feb 18, 2025

    @NJ-2020
    Contributor

    Proposal

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

    Unapprove button is showing instead of Cancel payment button on reports queued for ACH reimbursement (and incorrect sys message when actioned on from OldDot)

    What is the root cause of that problem?

    • The cancel payment will be shown based on this condition

      const shouldShowCancelPaymentButton = caseID === CASES.MONEY_REPORT && isPayer && isSettled && isExpenseReportUtil(moneyRequestReport);

      The isSettled function is returning false because we're returning false if isWaitingOnBankAccount is true
      const isSettled = isSettledUtil(moneyRequestReport?.reportID);

      App/src/libs/ReportUtils.ts

      Lines 1256 to 1276 in 1eb00b0

      function isSettled(reportOrID: OnyxInputOrEntry<Report> | SearchReport | string | undefined, reports?: SearchReport[]): boolean {
      if (!reportOrID) {
      return false;
      }
      const report = typeof reportOrID === 'string' ? getReport(reportOrID, reports ?? allReports) ?? null : reportOrID;
      if (!report) {
      return false;
      }
      if (isEmptyObject(report) || report.isWaitingOnBankAccount) {
      return false;
      }
      // In case the payment is scheduled and we are waiting for the payee to set up their wallet,
      // consider the report as paid as well.
      if (report.isWaitingOnBankAccount && report.statusNum === CONST.REPORT.STATUS_NUM.APPROVED) {
      return true;
      }
      return report?.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;
      }

    • The Unapprove option is displayed because we're not checking here if the money report is settled or not or specifically report.statusNum !== CONST.REPORT.STATUS_NUM.REIMBURSED

      const canUnapproveRequest = isExpenseReportUtil(report) && (isReportManagerUtil(report) || isPolicyAdmin) && isReportApprovedUtil({report}) && !isSubmitAndClose(policy);

    • For the report action message saying canceled the $0.00 payment it's BE issue, because the BE doesn't return any amount or currency inside reportAction originalMessage/message

    Image

    So when we're getting right here it will return null or $0.00

    App/src/libs/ReportUtils.ts

    Lines 2927 to 2936 in 1eb00b0

    function getReimbursementDeQueuedActionMessage(
    reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED>>,
    reportOrID: OnyxEntry<Report> | string | SearchReport,
    isLHNPreview = false,
    ): string {
    const report = typeof reportOrID === 'string' ? getReport(reportOrID, allReports) : reportOrID;
    const originalMessage = getOriginalMessage(reportAction);
    const amount = originalMessage?.amount;
    const currency = originalMessage?.currency;
    const formattedAmount = convertToDisplayString(amount, currency);

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

    • For the cancel payment option, inside this condition instead of isSettled we can check if the statusNum is reimbursed, so it will be:

      App/src/libs/ReportUtils.ts

      Lines 1265 to 1267 in 1eb00b0

      if (isEmptyObject(report) || report.isWaitingOnBankAccount) {
      return false;
      }
    const shouldShowCancelPaymentButton = caseID === CASES.MONEY_REPORT && isPayer && moneyRequestReport?.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED && isExpenseReportUtil(moneyRequestReport);

    Note

    If we change the isSettled function inside the ReportUtils to return true even if isWaitingOnBankAccount it will cause many bugs/issues as shown in this picture
    Image

    • And for the Unapprove option, we need to check if the money report is not settled or the money report status num is not equal to reimbursed
    const canUnapproveRequest = isExpenseReportUtil(report) && (isReportManagerUtil(report) || isPolicyAdmin) && isReportApprovedUtil({report}) && !isSubmitAndClose(policy) && !isSettled;
    // or
    const canUnapproveRequest = isExpenseReportUtil(report) && (isReportManagerUtil(report) || isPolicyAdmin) && isReportApprovedUtil({report}) && !isSubmitAndClose(policy) && moneyRequestReport?.statusNum !== CONST.REPORT.STATUS_NUM.REIMBURSED;
    • And for the report action message saying canceled the $0.00 payment, I think we should fix this in the BE side because if we use this FE solution by using the report?.total and then use the getMoneyRequestSpendBreakdown to get the totalDisplaySpend, the report action message will appear correctly but when we Unapprove the report, the report.total value is gone, and the report action message become incorrect again
    function getReimbursementDeQueuedActionMessage(
        reportAction: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED>>,
        reportOrID: OnyxEntry<Report> | string | SearchReport,
        isLHNPreview = false,
    ): string {
        const report = typeof reportOrID === 'string' ? getReport(reportOrID, allReports) : reportOrID;
        const originalMessage = getOriginalMessage(reportAction);
        const {totalDisplaySpend: totalReportDisplaySpend} = getMoneyRequestSpendBreakdown(report);
        const amount = originalMessage?.amount ?? totalReportDisplaySpend;
        const currency = originalMessage?.currency ?? report?.currency;
        const formattedAmount = convertToDisplayString(amount, currency);
        if (originalMessage?.cancellationReason === CONST.REPORT.CANCEL_PAYMENT_REASONS.ADMIN) {
            const payerOrApproverName = report?.managerID === currentUserAccountID || !isLHNPreview ? '' : getDisplayNameForParticipant({accountID: report?.managerID, shouldUseShortForm: true});
            return translateLocal('iou.adminCanceledRequest', {manager: payerOrApproverName, amount: formattedAmount});
        }
        const submitterDisplayName = getDisplayNameForParticipant({accountID: report?.ownerAccountID, shouldUseShortForm: true}) ?? '';
        return translateLocal('iou.canceledRequest', {submitterDisplayName, amount: formattedAmount});
    }

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

    We should create unit test function to cover this cases

    • The isSettled function should return true with money request report if the isWaitingOnBankAccount is true
    • For the Unapprove option we can use the ReportDetailsPage testID and make sure it doesn't contain any Unapprove option text
    • And for the report action message saying canceled the $0.00 payment, we need to check the getReimbursementDeQueuedActionMessage to return the correct message

    What alternative solutions did you explore? (Optional)

  10. bernhardoj commented on Feb 18, 2025

    @bernhardoj
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-02-24 03:36:31 UTC.

    Proposal

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

    When paying an expense with a pending bank account, unapprove is shown instead of cancel payment.

    What is the root cause of that problem?

    When we are waiting for bank account, the report status is APPROVED. The cancel payment will show if the report is settled. In isSettled function, we already have a logic to return true if the status is APPROVED and is currently waiting for bank account.

    const shouldShowCancelPaymentButton = caseID === CASES.MONEY_REPORT && isPayer && isSettled && isExpenseReportUtil(moneyRequestReport);

    App/src/libs/ReportUtils.ts

    Lines 1265 to 1273 in 011fd6c

    if (isEmptyObject(report) || report.isWaitingOnBankAccount) {
    return false;
    }
    // In case the payment is scheduled and we are waiting for the payee to set up their wallet,
    // consider the report as paid as well.
    if (report.isWaitingOnBankAccount && report.statusNum === CONST.REPORT.STATUS_NUM.APPROVED) {
    return true;
    }

    However, the logic is never reached because we return false if isWaitingOnBankAccount is true, so the cancel payment is not shown. On the other hand, since the status is APPROVED, isReportApproved is true, so the unapprove button is shown.

    const canUnapproveRequest = isExpenseReportUtil(report) && (isReportManagerUtil(report) || isPolicyAdmin) && isReportApprovedUtil({report}) && !isSubmitAndClose(policy);

    App/src/libs/ReportUtils.ts

    Lines 1213 to 1217 in 011fd6c

    function isReportApproved({report, parentReportAction = undefined}: {report: OnyxInputOrEntry<Report>; parentReportAction?: OnyxEntry<ReportAction> | undefined}): boolean {
    if (!report) {
    return parentReportAction?.childStateNum === CONST.REPORT.STATE_NUM.APPROVED && parentReportAction?.childStatusNum === CONST.REPORT.STATUS_NUM.APPROVED;
    }
    return report?.stateNum === CONST.REPORT.STATE_NUM.APPROVED && report?.statusNum === CONST.REPORT.STATUS_NUM.APPROVED;

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

    First of all, this logic shouldn't be put inside the isSettled function because isSettled is currently used to check whether the report is completely paid or not. But the condition is never true, so it never causes an issue, so we can just remove it too.

    App/src/libs/ReportUtils.ts

    Lines 1269 to 1273 in 0b6d1a0

    // In case the payment is scheduled and we are waiting for the payee to set up their wallet,
    // consider the report as paid as well.
    if (report.isWaitingOnBankAccount && report.statusNum === CONST.REPORT.STATUS_NUM.APPROVED) {
    return true;
    }

    To fix this issue, we need to update shouldShowCancelPaymentButton so it returns true if the report is either settled or waiting on bank account.

    const shouldShowCancelPaymentButton = caseID === CASES.MONEY_REPORT && isPayer && isSettled && isExpenseReportUtil(moneyRequestReport);

    const shouldShowCancelPaymentButton = caseID === CASES.MONEY_REPORT && isPayer && (isSettled || report.isWaitingOnBankAccount) && isExpenseReportUtil(moneyRequestReport);
    

    This is consistent with other parts of the app.

    if (iouSettled || iouReport?.isWaitingOnBankAccount) {
    paymentVerb = 'iou.payerPaid';

    App/src/libs/ReportUtils.ts

    Lines 3993 to 3994 in 0b6d1a0

    // Show Paid preview message if it's settled or if the amount is paid & stuck at receivers end for only chat reports.
    if (isSettled(report.reportID) || (report.isWaitingOnBankAccount && isPreviewMessageForParentChatReport)) {

    Second, we need to update canUnapproveRequest so it returns false if we are waiting for bank account.

    const canUnapproveRequest = isExpenseReportUtil(report) && (isReportManagerUtil(report) || isPolicyAdmin) && isReportApprovedUtil({report}) && !isSubmitAndClose(policy);

    const canUnapproveRequest = ... && !report.isWaitingOnBankAccount;
    

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

    To be able to test it, we can move canUnapproveRequest and shouldShowCancelPaymentButton to a util function and test both functions.

  11. melvin-bot commented on Feb 21, 2025

    @melvin-bot

    @trjExpensify, @rayane-d Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  12. 22 remaining items

  13. melvin-bot commented on Mar 6, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.9-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-03-13. 🎊

    For reference, here are some details about the assignees on this issue:

    • @bernhardoj requires payment through NewDot Manual Requests
    • @rayane-d requires payment through NewDot Manual Requests
  14. melvin-bot commented on Mar 6, 2025

    @melvin-bot

    @rayane-d @trjExpensify @rayane-d The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. rayane-d commented on Mar 7, 2025

    @rayane-d
    Contributor

    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: https://github.com/Expensify/App/pull/34719/files#r1985359043

    • [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: N/A

    • [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:

    Regression Test Proposal

    Precondition:

    • USD workspace with ACH reimbursement and Add approvals enabled
    • Haven't added a personal bank account yet.

    Test:

    1. Open your workspace chat
    2. Submit a money request
    3. Open the expense report
    4. Approve it
    5. Pay with expensify
    6. Press the report header
    7. Verify a Cancel payment option is shown
    8. Verify there is no Unapprove option
    9. Press the Cancel payment
    10. Press the report header again
    11. Verify there is now an Unapprove option

    Do we agree 👍 or 👎

  16. trjExpensify commented on Mar 13, 2025

    @trjExpensify
    ContributorAuthor

    Nice one, regression test created. Payment summary as follows:

    Go ahead and request. Closing, thanks!

  17. moved this from Bugs and Follow Up Issues to Done in #expensify-bugson Mar 13, 2025
  18. bernhardoj commented on Mar 13, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  19. JmillsExpensify commented on Mar 17, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  20. rayane-d commented on Mar 18, 2025

    @rayane-d
    Contributor

    Requested in ND

  21. garrettmknight commented on Mar 24, 2025

    @garrettmknight
    Contributor

    $250 approved for @rayane-d

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions