Skip to content

[HOLD for payment 2024-07-10] [$250] Track expense - "Delete expense" option appears for paid tracked expense #43591

Closed

Description

@lanitochka17

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: 1.4.82-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit an expense
  4. Track an expense
  5. Pay elsewhere the expense report
  6. Go to transaction thread of tracked expense
  7. Click 3-dot menu

Expected Result:

"Delete expense" option will not appear for paid tracked expense

Actual Result:

"Delete expense" option appears for paid tracked expense

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6511017_1718207360141.20240612_234631.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01bb7f209695580cf5
  • Upwork Job ID: 1802802568068548628
  • Last Price Increase: 2024-06-17
  • Automatic offers:
    • eh2077 | Reviewer | 102806652
    • bernhardoj | Contributor | 102806654
Issue OwnerCurrent Issue Owner: @kevinksullivan

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 12, 2024
  2. melvin-bot commented on Jun 12, 2024

    @melvin-bot

    Triggered auto assignment to @kevinksullivan (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. lanitochka17 commented on Jun 12, 2024

    @lanitochka17
    Author

    @kevinksullivan FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

  4. cretadn22 commented on Jun 12, 2024

    @cretadn22
    Contributor

    Proposal

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

    "Delete expense" option appears for paid tracked expense

    What is the root cause of that problem?

    const canDeleteRequest =
    isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || ReportUtils.isTrackExpenseReport(transactionThreadReport)) && !isDeletedParentAction;

    We manually add isTrackExpenseReport condition to display the delete option in paid track expense

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

    Before we need to add isTrackExpenseReport condition because canAddOrDeleteTransactions doesn't cover track expense case. At present, let's remove isTrackExpenseReport condition because canAddOrDeleteTransactions also cover track expense case.

    Consider to make the same fix to MoneyRequestHeader

    What alternative solutions did you explore? (Optional)

  5. bernhardoj commented on Jun 13, 2024

    @bernhardoj
    Contributor

    Proposal

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

    Delete expense option is shown for paid track expense.

    What is the root cause of that problem?

    The delete option is always shown for track expense report.

    const canDeleteRequest = isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || ReportUtils.isTrackExpenseReport(report)) && !isDeletedParentAction;

    This is useful for self DM track expense report because the moneyRequestReport is the parent report which is self DM,

    const moneyRequestReport = parentReport;

    so canAddOrDeleteTransactions returns false for selfDM track expense. In a normal money request or workspace track expense, we have IOU/expense report and then the transaction thread.

    chat report -> money request report -> transaction thread

    But in self DM track expense, we only have the track expense report/transaction thread

    self DM -> track expense report

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

    We need to also check whether the track expense is a self DM track or not.

    const isSelfDMTrack = ReportUtils.isTrackExpenseReport(report) && ReportUtils.isSelfDM(parentReport);
    const moneyRequestReport = !isSelfDMTrack ? parentReport : undefined; <- optional, just so it's more predictable
    const canDeleteRequest = ... && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || isSelfDMTrack) && ...
    

    We also have the same condition in MoneyReportHeader that is shown in the money request report, but self DM track doesn't have money request report, so we can remove it (remove ReportUtils.isTrackExpenseReport(report))

    const canDeleteRequest =
    isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || ReportUtils.isTrackExpenseReport(transactionThreadReport)) && !isDeletedParentAction;

    What alternative solutions did you explore? (Optional)

    In canAddOrDeleteTransactions, returns true if it's a self DM.

    App/src/libs/ReportUtils.ts

    Lines 1506 to 1509 in a451de4

    function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): boolean {
    if (!isMoneyRequestReport(moneyRequestReport)) {
    return false;
    }

    if (isSelfDM(moneyRequestReport)) return true
    

    But I don't like this one because canAddOrDeleteTransactions is expected to work with a money request report.

    Instead, we can add a new optional param to canAddOrDeleteTransactions called transactionReport and if transactionReport is a self DM track, then returns true.

  6. melvin-bot commented on Jun 17, 2024

    @melvin-bot

    @kevinksullivan Huh... This is 4 days overdue. Who can take care of this?

  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 17, 2024
  8. changed the title [-]Track expense - "Delete expense" option appears for paid tracked expense[/-] [+][$250] Track expense - "Delete expense" option appears for paid tracked expense[/+] on Jun 17, 2024
  9. melvin-bot commented on Jun 17, 2024

    @melvin-bot
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 17, 2024
  11. 19 remaining items

  12. melvin-bot commented on Jul 3, 2024

    @melvin-bot

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

  13. melvin-bot commented on Jul 3, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.3-7 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 2024-07-10. 🎊

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

  14. melvin-bot commented on Jul 3, 2024

    @melvin-bot

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@eh2077] The PR that introduced the bug has been identified. Link to the PR:
    • [@eh2077] 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:
    • [@eh2077] A discussion in #expensify-bugs 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:
    • [@eh2077] Determine if we should create a regression test for this bug.
    • [@eh2077] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@kevinksullivan] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  15. eh2077 commented on Jul 14, 2024

    @eh2077
    Contributor

    Checklist

    • [@eh2077] The PR that introduced the bug has been identified. Link to the PR: I can't find the specific PR that is responsible for this bug. We missed this case when adding the track expense feature to workspace.
    • [@eh2077] 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: N/A
    • [@eh2077] A discussion in #expensify-bugs 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
    • [@eh2077] Determine if we should create a regression test for this bug. Yes

    Regression test

    1. Open workspace chat
    2. Submit 1 expense and track 1 expense
    3. Open the expense report
    4. Pay the expense
    5. Open the track transaction thread
    6. Press the 3-dot button
    7. Verify there is no Delete expense option
    8. Open a self DM
    9. Track an expense
    10. Open the track report
    11. Press the 3-dot button
    12. Verify there is a Delete expense option

    Do we agree 👍 or 👎

  16. bernhardoj commented on Jul 14, 2024

    @bernhardoj
    Contributor

    I requested the payment in ND.

  17. melvin-bot commented on Jul 15, 2024

    @melvin-bot

    @NikkiWines, @kevinksullivan, @bernhardoj, @eh2077 Eep! 4 days overdue now. Issues have feelings too...

  18. kevinksullivan commented on Jul 15, 2024

    @kevinksullivan
    Contributor

    Payment summary:

  19. kevinksullivan commented on Jul 15, 2024

    @kevinksullivan
    Contributor

    All set paying @eh2077

  20. JmillsExpensify commented on Jul 16, 2024

    @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 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