Skip to content

[$250] Track expense - Unable to delete track scan expense while scanning #64701

Closed

Description

@jponikarchuk

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.1.70-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exploratory
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Device used: Win 11/Chrome
App Component: Money Requests

Action Performed:

  1. Open https://staging.new.expensify.com
  2. Navigate to the self DM
  3. Create a scan expense
  4. Click on this expense while it's still scanning
  5. Click on More
  6. Click Delete

Expected Result:

This expense should be deleted

Actual Result:

This expense isn't deleted

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

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021937302120868579148
  • Upwork Job ID: 1937302120868579148
  • Last Price Increase: 2025-07-01
Issue OwnerCurrent Issue Owner: @amyevans

Activity

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

    @melvin-bot

    Triggered auto assignment to @johncschuster (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. ryntgh commented on Jun 21, 2025

    @ryntgh
    Contributor

    Proposal

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

    Track expense - Unable to delete track scan expense while scanning

    What is the root cause of that problem?

    When calling deleteTrackExpense, report?.chatReportID passes undefined for scan expenses that are still processing in Self DM

    if (isTrackExpenseAction(parentReportAction)) {
    deleteTrackExpense(report?.chatReportID, transaction.transactionID, parentReportAction, true);
    } else {
    deleteMoneyRequest(transaction.transactionID, parentReportAction, true);
    removeTransaction(transaction.transactionID);
    }

    When a receipt is still scanning, the transaction thread report chatReportID property is undefined, while the parent Self DM report reportID is already available. Once scanning completes, both values become the same

    Currently, we call deleteTrackExpense with undefined as the first parameter, so it cannot properly identify the Self DM chat report to update, causing the function to fail to trigger DeleteMoneyRequest

    This behavior also occurs with distance expenses when the route is not defined, and when creating and deleting a manual expense in offline mode. When returning online, the report is not deleted because report?.chatReportID passes undefined

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

    Update the deleteTrackExpense call to use parentReport?.reportID instead of report?.chatReportID

                        if (isTrackExpenseAction(parentReportAction)) {
                            deleteTrackExpense(parentReport?.reportID, transaction.transactionID, parentReportAction, true);

    if (isTrackExpenseAction(parentReportAction)) {
    deleteTrackExpense(report?.chatReportID, transaction.transactionID, parentReportAction, true);

    This ensures that the correct Self DM chat report ID is always passed to deleteTrackExpense, regardless of whether the scan is still in progress or completed

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

    N/A

    What alternative solutions did you explore? (Optional)

    Or we can use report?.parentReportID

                        if (isTrackExpenseAction(parentReportAction)) {
                            deleteTrackExpense(report?.parentReportID, transaction.transactionID, parentReportAction, true);
  4. thelullabyy commented on Jun 23, 2025

    @thelullabyy
    Contributor

    Proposal

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

    This expense isn't deleted

    What is the root cause of that problem?

    The report?.chatReportID is undefined so this function do nothing.

    if (isTrackExpenseAction(parentReportAction)) {
    deleteTrackExpense(report?.chatReportID, transaction.transactionID, parentReportAction, true);
    } else {
    deleteMoneyRequest(transaction.transactionID, parentReportAction, true);
    removeTransaction(transaction.transactionID);
    }

    report?.chatReportID is undefined because we don't add this in the optimistic data of the transaction thread report. If we open the transaction thread report, the OpenReport API will return chatReportID is the parent report

    const transactionThread = buildTransactionThread(iouAction, iouReport, existingTransactionThreadReportID);

    App/src/libs/ReportUtils.ts

    Lines 7702 to 7710 in b8ef627

    return buildOptimisticChatReport({
    participantList: participantAccountIDs,
    reportName: getTransactionReportName({reportAction}),
    policyID: moneyRequestReport?.policyID,
    ownerAccountID: CONST.POLICY.OWNER_ACCOUNT_ID_FAKE,
    notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
    parentReportActionID: reportAction?.reportActionID,
    parentReportID: moneyRequestReport?.reportID,
    });

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

    From what I see, the chatReportID is the same as parentReportID, then we can add chatReportID when we create the optimistic chat report here

    chatReportID: parentReportID,
    

    App/src/libs/ReportUtils.ts

    Lines 6916 to 6918 in b8ef627

    const optimisticChatReport: OptimisticChatReport = {
    type: CONST.REPORT.TYPE.CHAT,
    chatType,

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

    Update buildOptimisticChatReport unit test to verify the chatReportID exists if parentReportID is not empty.

    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.

  5. added
    External
    on Jun 24, 2025
  6. changed the title [-]Track expense - Unable to delete track scan expense while scanning[/-] [+][$250] Track expense - Unable to delete track scan expense while scanning[/+] on Jun 24, 2025
  7. melvin-bot commented on Jun 24, 2025

    @melvin-bot
  8. added
    Help Wanted
    on Jun 24, 2025
  9. melvin-bot commented on Jun 24, 2025

    @melvin-bot

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

  10. 6 remaining items

  11. thelullabyy commented on Jun 27, 2025

    @thelullabyy
    Contributor

    When a receipt is still scanning, the transaction thread report chatReportID property is undefined, while the parent Self DM report reportID is already available. Once scanning completes, both values become the same

    @akinwale The chatReportID is missing in the optimistic data then we should fix this instead of using another field. Additionally, the chatReportID is always returned in the OpenReport API, no need to wait scanning completes

  12. melvin-bot commented on Jun 30, 2025

    @melvin-bot

    @amyevans Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  13. amyevans commented on Jun 30, 2025

    @amyevans
    Contributor

    @akinwale The chatReportID is missing in the optimistic data then we should fix this instead of using another field. Additionally, the chatReportID is always returned in the OpenReport API, no need to wait scanning completes

    @akinwale What do you think about that? Without doing a deeper dive it seems like a cleaner solution to me but I would like your take having reviewed them. Thanks!

  14. ryntgh commented on Jul 1, 2025

    @ryntgh
    Contributor

    The issue is no longer reproducible, as it was fixed in this PR, which uses the exact same solution as my proposal

    Would @akinwale and I be eligible for partial payment as compensation, based on this comment and this Slack thread?

  15. akinwale commented on Jul 1, 2025

    @akinwale
    Contributor

    Would @akinwale and I be eligible for partial payment as compensation, based on this comment and this Slack thread?

    Yes, 50% of the original price is due here for both the contributor and the C+ respectively.

    cc @johncschuster

  16. akinwale commented on Jul 1, 2025

    @akinwale
    Contributor

    @akinwale The chatReportID is missing in the optimistic data then we should fix this instead of using another field. Additionally, the chatReportID is always returned in the OpenReport API, no need to wait scanning completes

    @akinwale What do you think about that? Without doing a deeper dive it seems like a cleaner solution to me but I would like your take having reviewed them. Thanks!

    @amyevans Since the required value was already present as a different property, I thought it was preferable to go with the simpler option instead of having to update the optimistic data.

    Coincidentally, it looks like the same idea was implemented independently, twice: #64632 and #63297.

  17. johncschuster commented on Jul 1, 2025

    @johncschuster
    Contributor

    Payment Summary

    Contributor: @ryntgh paid $125 via Upwork ✅
    Contributor+: @akinwale due $125 via NewDot

    @ryntgh please accept the offer above so I can pay that out for you!

  18. ryntgh commented on Jul 1, 2025

    @ryntgh
    Contributor

    Offer accepted!

  19. melvin-bot commented on Jul 1, 2025

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  20. johncschuster commented on Jul 2, 2025

    @johncschuster
    Contributor

    @akinwale please go ahead and request payment here!

  21. JmillsExpensify commented on Jul 2, 2025

    @JmillsExpensify
    Contributor

    $125 approved for @akinwale

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

Metadata

Metadata

Labels

BugDailyExternalHelp Wanted

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions