Skip to content

[Due for payment 2025-10-09] [$250] Chat-Delete expense in offline remove them immediately instead of grey out #70185

Closed

Description

@nlemma

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.2.3-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: #69872
Email or phone of affected tester (no customers): ndk.2303+approver@gmail.com
Issue reported by: Applause Internal Team
Device used: Windows 11 Home/Chrome
App Component: Money Requests

Action Performed:

  1. Open https://staging.new.expensify.com/
  2. Create 2 expense in 1 report
  3. Navigate to the report
  4. Go offline
  5. Delete 1 expense

Expected Result:

When delete expense in offline mode, it should be grey out and strikethrough

Actual Result:

The expense is removed immediately when delete it in offline mode

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

2025-09-23_12-54-08.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021965420260416143565
  • Upwork Job ID: 1965420260416143565
  • Last Price Increase: 2025-09-09
  • Automatic offers:
    • nkdengineer | Contributor | 108881001
Issue OwnerCurrent Issue Owner: @bfitzexpensify

Activity

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

    @melvin-bot

    Triggered auto assignment to @bfitzexpensify (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 Sep 9, 2025

    @nkdengineer
    Contributor

    Proposal

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

    The expense is removed immediately when delete it in offline mode

    What is the root cause of that problem?

    We already avoid filtering out the pending delete transaction in visibleTransactions, but it's filtered out in getAllNonDeletedTransactions

    const reportTransactions = useMemo(() => getAllNonDeletedTransactions(allReportTransactions, reportActions), [allReportTransactions, reportActions]);
    // wrapping in useMemo because this is array operation and can cause performance issues
    const visibleTransactions = useMemo(
    () => reportTransactions?.filter((transaction) => isOffline || transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE),
    [reportTransactions, isOffline],
    );
    const reportTransactionIDs = useMemo(() => visibleTransactions?.map((transaction) => transaction.transactionID), [visibleTransactions]);

    Then the one transaction view appears because we only have one transaction.

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

    We should introduce isOffline parameter in getAllNonDeletedTransactions function, and don't filter out the transaction if it's pending delete or the iou action related to this one is pending delete. If we always want to keep the pending delete transaction, we can do the logic without isOffline param. Small improvement can be done in the PR.

    function getAllNonDeletedTransactions(transactions: OnyxCollection<Transaction>, reportActions: ReportAction[], isOffline = false) {
        return Object.values(transactions ?? {}).filter((transaction): transaction is Transaction => {
            if (!transaction) {
                return false;
            }
            const action = getIOUActionForTransactionID(reportActions, transaction.transactionID);
            if (action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && isOffline) {
                return true;
            }
            return !isDeletedParentAction(action) && (reportActions.length === 0 || !isDeletedAction(action));
        });
    }
    

    And then we pass isOffline to getAllNonDeletedTransactions here.

    const reportTransactions = useMemo(() => getAllNonDeletedTransactions(allReportTransactions, reportActions), [allReportTransactions, reportActions]);
    // wrapping in useMemo because this is array operation and can cause performance issues
    const visibleTransactions = useMemo(
    () => reportTransactions?.filter((transaction) => isOffline || transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE),
    [reportTransactions, isOffline],
    );
    const reportTransactionIDs = useMemo(() => visibleTransactions?.map((transaction) => transaction.transactionID), [visibleTransactions]);

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

    Test getAllNonDeletedTransactions function and verify that this function keep the pending delete transaction when isOffline parameter is true.

    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. dmkt9 commented on Sep 9, 2025

    @dmkt9
    Contributor

    Proposal

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

    The expense is removed immediately when delete it in offline mode

    What is the root cause of that problem?

    Because the getAllNonDeletedTransactions function filters out transactions that are pending deletion, even though visibleTransactions has an exception for offline mode, those pending-deletion transactions are still excluded from the list:

    function getAllNonDeletedTransactions(transactions: OnyxCollection<Transaction>, reportActions: ReportAction[]) {
    return Object.values(transactions ?? {}).filter((transaction): transaction is Transaction => {
    if (!transaction) {
    return false;
    }
    const action = getIOUActionForTransactionID(reportActions, transaction.transactionID);
    return !isDeletedParentAction(action) && (reportActions.length === 0 || !isDeletedAction(action));
    });
    }

    const reportTransactions = useMemo(() => getAllNonDeletedTransactions(allReportTransactions, reportActions), [allReportTransactions, reportActions]);
    // wrapping in useMemo because this is array operation and can cause performance issues
    const visibleTransactions = useMemo(
    () => reportTransactions?.filter((transaction) => isOffline || transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE),
    [reportTransactions, isOffline],
    );

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

    We should allow transactions with pending deletion actions to pass through getAllNonDeletedTransactions, and defer the filtering logic to visibleTransactions.

    const action = getIOUActionForTransactionID(reportActions, transaction.transactionID);

    const action = getIOUActionForTransactionID(reportActions, transaction.transactionID);
    + if (action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
    +     return true;
    + }

    Note: It may be worth reviewing all usages of getAllNonDeletedTransactions and adjusting them accordingly if needed.

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

    Add test coverage for getAllNonDeletedTransactions.

    What alternative solutions did you explore? (Optional)

    NA

    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
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 9, 2025
  6. changed the title [-]Chat-Delete expense in offline remove them immediately instead of grey out[/-] [+][$250] Chat-Delete expense in offline remove them immediately instead of grey out[/+] on Sep 9, 2025
  7. melvin-bot commented on Sep 9, 2025

    @melvin-bot
  8. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 9, 2025
  9. moved this to Bugs and Follow Up Issues in #expensify-bugson Sep 9, 2025
  10. melvin-bot commented on Sep 9, 2025

    @melvin-bot

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

  11. suneox commented on Sep 10, 2025

    @suneox
    Contributor

    @nkdengineer proposal LGTM

    🎀 👀 🎀 C+ reviewed

  12. 23 remaining items

  13. melvin-bot commented on Oct 2, 2025

    @melvin-bot

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

  14. melvin-bot commented on Oct 2, 2025

    @melvin-bot

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

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

  15. melvin-bot commented on Oct 2, 2025

    @melvin-bot

    @suneox @bfitzexpensify 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]

  16. suneox commented on Oct 12, 2025

    @suneox
    Contributor

    BugZero Checklist:

    • [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/65247/files#r2424620671

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

      N/A: It isn't an impactful bug

  17. bfitzexpensify commented on Oct 14, 2025

    @bfitzexpensify
    Contributor

    @nkdengineer please accept the Upwork job offer.

    Payment summary:

    @suneox due $250 via NewDot Manual Requests
    @nkdengineer due $250 via Upwork

  18. nkdengineer commented on Oct 15, 2025

    @nkdengineer
    Contributor

    @bfitzexpensify I will get paid via NewDot

  19. bfitzexpensify commented on Oct 15, 2025

    @bfitzexpensify
    Contributor

    OK, great.

    Payment summary:

    @nkdengineer due $250 via NewDot Manual Requests

  20. moved this from Bugs and Follow Up Issues to Done in #expensify-bugson Oct 15, 2025
  21. twisterdotcom commented on Oct 26, 2025

    @twisterdotcom
    Contributor

    @suneox has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-5f58-a12d-b7de-5c89bf6996b1
  22. JmillsExpensify commented on Nov 4, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @nkdengineer

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 contributorWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions