Skip to content

[Due for payment 2025-02-28] [$250] Delete expene missing after cancel payment #55319

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.0.86-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
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: @dukenv0307
Slack conversation (hyperlinked to channel name): expensify_bugs

Action Performed:

  1. Create an expense
  2. Go to offline
  3. Click pay elsewhere
  4. Click report header -> Cancel payment
  5. Click report header again

Expected Result:

Delete expense button is missing

Actual Result:

Delete expense button is displayed

Workaround:

Unknown

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

Add any screenshot/video evidence
bug-resize.1.mp4
Recording.891.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021881632041880939700
  • Upwork Job ID: 1881632041880939700
  • Last Price Increase: 2025-02-11
  • Automatic offers:
    • twilight2294 | Contributor | 106099552
Issue OwnerCurrent Issue Owner: @sonialiap

Activity

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

    @melvin-bot

    Triggered auto assignment to @sonialiap (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. nkdengineer commented on Jan 15, 2025

    @nkdengineer
    Contributor

    Proposal

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

    Delete expenes missing after cancel payment

    What is the root cause of that problem?

    After cancel payment, we are updating statusNum = CONST.REPORT.STATUS_NUM.CLOSED when approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL here

    App/src/libs/actions/IOU.ts

    Lines 7910 to 7912 in 332c9b0

    const approvalMode = policy?.approvalMode ?? CONST.POLICY.APPROVAL_MODE.BASIC;
    const stateNum: ValueOf<typeof CONST.REPORT.STATE_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATE_NUM.SUBMITTED : CONST.REPORT.STATE_NUM.APPROVED;
    const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED;

    It leads to isProcessingReport(moneyRequestReport) will be false

    App/src/libs/ReportUtils.ts

    Lines 1992 to 1994 in 332c9b0

    if (isInstantSubmitEnabled(policy) && isProcessingReport(moneyRequestReport)) {
    return isAwaitingFirstLevelApproval(moneyRequestReport);
    }

    And in function canAddOrDeleteTransactions we return false here

    App/src/libs/ReportUtils.ts

    Lines 1996 to 1998 in 332c9b0

    if (isReportApproved(moneyRequestReport) || isClosedReport(moneyRequestReport) || isSettled(moneyRequestReport?.reportID)) {
    return false;
    }

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

    We should update statusNum to CONST.REPORT.STATUS_NUM.SUBMITTED like BE is returning

       const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.SUBMITTED : CONST.REPORT.STATUS_NUM.APPROVED;
    

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

    What alternative solutions did you explore? (Optional)

    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.

  4. github-actions commented on Jan 15, 2025

    @github-actions
    Contributor

    ⚠️ @nkdengineer Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format.

  5. dukenv0307 commented on Jan 16, 2025

    @dukenv0307
    Contributor

    @sonialiap I have the prior context on this issue so I can help take it as C+. Thanks

  6. twilight2294 commented on Jan 16, 2025

    @twilight2294
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-01-16 06:50:00 UTC.

    Proposal

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

    There are 2 bugs in this flow:

    1. Delete expene missing after cancel payment.
    2. The optimistic message (next step) for policy with instant submit enabled is wrong ( doesn't match with what the backend returns)

    What is the root cause of that problem?

    1. When we cancel the payment, we set the statusNum to CONST.REPORT.STATUS_NUM.CLOSED when the policy approval mode is optional, this causes the bug in offline case where the delete and hold button are hidden. when we get api response from the BE, statusNum is correctly set to CONST.REPORT.STATUS_NUM.SUBMITTED.

      const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED;

    2. Now, when we cancel payment, the next steps for a policy with no approval flow enabled is to pay for the expense again. but now we see that no action is required (Which changes again when we get the response from the BE api).

    Image

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

    1. We need to update the statusNum to CONST.REPORT.STATUS_NUM.SUBMITTED here:
    const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.SUBMITTED : CONST.REPORT.STATUS_NUM.APPROVED;
    1. Now we also need to update the nextSteps here, because with only the above change there will be a regression that we will always show that Waiting for (name) to approve expense(s). regardless of if the policy has approval flow enabled or not, only doing the change in 1. will cause this regression.

    So we need to fix this one too, to do that we need to update the following case:

    // Generates an optimistic nextStep once a report has been submitted
    case CONST.REPORT.STATUS_NUM.SUBMITTED: {

    here, we will put a if condition for the message:

    message: [

    To display only when autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT and for other cases we can directly show the waiting for payment message optimistically, we need to make changes as follows:

    Details
    --- a/src/libs/NextStepUtils.ts
    +++ b/src/libs/NextStepUtils.ts
    @@ -5,7 +5,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
     import type {ValueOf} from 'type-fest';
     import CONST from '@src/CONST';
     import ONYXKEYS from '@src/ONYXKEYS';
    -import type {Policy, Report, ReportNextStep} from '@src/types/onyx';
    +import type {Policy, Report, ReportNextStep, Session} from '@src/types/onyx';
     import type {Message} from '@src/types/onyx/ReportNextStep';
     import type DeepValueOf from '@src/types/utils/DeepValueOf';
     import {getNextApproverAccountID} from './actions/IOU';
    @@ -16,6 +16,7 @@ import * as ReportUtils from './ReportUtils';
     
     let currentUserAccountID = -1;
     let currentUserEmail = '';
    +let session: Session;
     Onyx.connect({
         key: ONYXKEYS.SESSION,
         callback: (value) => {
    @@ -25,6 +26,7 @@ Onyx.connect({
     
             currentUserAccountID = value?.accountID ?? -1;
             currentUserEmail = value?.email ?? '';
    +        session = value;
         },
     });
     
    @@ -86,6 +88,7 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
         }
     
         const {policyID = '', ownerAccountID = -1} = report ?? {};
    +    const isPayer = ReportUtils.isPayer(session, report);
         const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] ?? ({} as Policy);
         const {harvesting, autoReportingOffset} = policy;
         const autoReportingFrequency = PolicyUtils.getCorrectedAutoReportingFrequency(policy);
    @@ -202,7 +205,10 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
                 optimisticNextStep = {
                     type,
                     icon: CONST.NEXT_STEP.ICONS.HOURGLASS,
    -                message: [
    +            };
    +
    +            if (autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT) {
    +                optimisticNextStep.message = [
                         {
                             text: 'Waiting for ',
                         },
    @@ -219,8 +225,32 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
                         {
                             text: ' %expenses.',
                         },
    -                ],
    -            };
    +                ];
    +            } else {
    +                optimisticNextStep.message = [
    +                    {
    +                        text: 'Waiting for ',
    +                    },
    +                    isPayer
    +                        ? {
    +                              text: `you`,
    +                              type: 'strong',
    +                          }
    +                        : {
    +                              text: `an admin`,
    +                              type: 'strong',
    +                          },
    +                    {
    +                        text: ' to ',
    +                    },
    +                    {
    +                        text: 'pay',
    +                    },
    +                    {
    +                        text: ' %expenses.',
    +                    },
    +                ];
    +            }
     
                 break;
    
    Note that there can be a few improvements during PR phase, Note that i think that only an admin can undo a payment so the above conditions wont be required for that case, we can simply do the following:
    
                } else {
                    optimisticNextStep.message = [
                        {
                            text: 'Waiting for ',
                        },
                        {
                            text: `you`,
                            type: 'strong',
                        },
    
                        {
                            text: ' to ',
                        },
                        {
                            text: 'pay',
                        },
                        {
                            text: ' %expenses.',
                        },
                    ];
    

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

    N/A this is a UI issue, but we can add additional nextStep tests to mock this action and see if we get correct message

    What alternative solutions did you explore? (Optional)

    N/A

  7. github-actions commented on Jan 16, 2025

    @github-actions
    Contributor

    ⚠️ @twilight2294 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jan 21, 2025
  9. changed the title [-]Delete expene missing after cancel payment[/-] [+][$250] Delete expene missing after cancel payment[/+] on Jan 21, 2025
  10. melvin-bot commented on Jan 21, 2025

    @melvin-bot
  11. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 21, 2025
  12. 64 remaining items

  13. changed the title [-][$250] Delete expene missing after cancel payment[/-] [+][Due for payment 2025-02-28] [$250] Delete expene missing after cancel payment[/+] on Feb 21, 2025
  14. melvin-bot commented on Feb 21, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  15. melvin-bot commented on Feb 21, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.3-4 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-02-28. 🎊

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

  16. melvin-bot commented on Feb 21, 2025

    @melvin-bot

    @dukenv0307 @sonialiap @dukenv0307 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]

  17. dukenv0307 commented on Feb 24, 2025

    @dukenv0307
    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
    • 2b. Reported on staging (deploy blocker)
    • 2c. 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/48700/files#r1967003299

    • [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. Yes

    Regression Test Proposal Template

    Regression Test Proposal

    Test:

    1. Create an expense
    2. Go to offline
    3. Click pay elsewhere
    4. Click report header -> Cancel payment
    5. Click report header again
    6. Delete expense button is displayed

    Do we agree 👍 or 👎

  18. moved this to Hold for Payment in #expensify-bugson Feb 25, 2025
  19. twilight2294 commented on Feb 28, 2025

    @twilight2294
    Contributor

    Can someone please pay me for this issue

  20. sonialiap commented on Feb 28, 2025

    @sonialiap
    Contributor

    Payment summary:

    • @dukenv0307 $250 please request in NewDot. Thanks for getting the checklist done!
    • @twilight2294 $250 paid in upwork ✔
  21. moved this from Hold for Payment to Done in #expensify-bugson Feb 28, 2025
  22. JmillsExpensify commented on Mar 12, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @dukenv0307

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