Skip to content

[Due for payment 2025-09-17] [$250] Distance - Waypoints are not cleared after relaunching app #69450

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: 9.2.0-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: Exp https://test-management.browserstack.com/projects/2219752/test-runs/TR-515/folder/13176744/41237142/864761862
Email or phone of affected tester (no customers): sdhshssdjiosdndjs@gmail.com
Issue reported by: Applause Internal Team
Device used: Samsung Galaxy Z Fold 4 / Android 15
App Component: Money Requests

Action Performed:

  1. Launch Expensify app.
  2. Open FAB > Create expense > Distance.
  3. Enter Start and Stop waypoints.
  4. On waypoints page, kill the app.
  5. Relaunch the app.
  6. Open FAB > Create expense > Distance.

Expected Result:

Waypoint fields will be cleared after relaunching app.

Actual Result:

Waypoint fields are not cleared after relaunching app.

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

Bug6929093_1756387784895.Screen_Recording_20250828_203101_Expensify.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021965100725678806793
  • Upwork Job ID: 1965100725678806793
  • Last Price Increase: 2025-09-08
Issue OwnerCurrent Issue Owner: @greg-schroeder

Activity

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

    @melvin-bot

    Triggered auto assignment to @greg-schroeder (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. bernhardoj commented on Aug 28, 2025

    @bernhardoj
    Contributor

    Proposal

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

    The distance waypoints are not cleared when reopen it after closing the app.

    What is the root cause of that problem?

    When we press the create expense option, we call removeDraftTransactions to remove all the draft transactions.

    App/src/libs/actions/IOU.ts

    Lines 1020 to 1027 in 10f648b

    function clearMoneyRequest(transactionID: string, skipConfirmation = false) {
    removeDraftTransactions();
    Onyx.set(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`, skipConfirmation);
    }
    function startMoneyRequest(iouType: ValueOf<typeof CONST.IOU.TYPE>, reportID: string, requestType?: IOURequestType, skipConfirmation = false, backToReport?: string) {
    Performance.markStart(CONST.TIMING.OPEN_CREATE_EXPENSE);
    clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, skipConfirmation);

    It gets the list of draft transaction from the Onyx.connect

    function removeDraftTransactions(shouldExcludeInitialTransaction = false) {
    const draftTransactions = getDraftTransactions();
    const draftTransactionsSet = draftTransactions.reduce(
    (acc, item) => {
    if (shouldExcludeInitialTransaction && item.transactionID === CONST.IOU.OPTIMISTIC_TRANSACTION_ID) {
    return acc;
    }
    acc[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${item.transactionID}`] = null;
    return acc;
    },
    {} as Record<string, null>,
    );
    return Onyx.multiSet(draftTransactionsSet);
    }

    function getDraftTransactions(): Transaction[] {
    return Object.values(allTransactionDrafts ?? {}).filter((transaction): transaction is Transaction => !!transaction);
    }

    let allTransactionDrafts: OnyxCollection<Transaction> = {};
    Onyx.connect({
    key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
    waitForCollectionCallback: true,
    callback: (value) => {
    allTransactionDrafts = value ?? {};
    },
    });

    However, when we call removeDraftTransactions after reopening the app, the list is empty. It's because inline require is enabled, and this Onyx.connect is only executed once we call the code from Transaction.ts.

    let allTransactionDrafts: OnyxCollection<Transaction> = {};
    Onyx.connect({
    key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
    waitForCollectionCallback: true,
    callback: (value) => {
    allTransactionDrafts = value ?? {};
    },
    });

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

    We need to pass the list of draft transaction keys using useOnyx.

    In FloatingActionButtonAndPopover,

    const [draftTransactionKeys = []] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: (value) => Object.keys(value ?? {})});
    

    then pass it down tostartMoneyRequest > clearMoneyRequest > removeDraftTransactions.

    const draftTransactionsSet = draftTransactionKeys.reduce(
        (acc, item) => {
            if (shouldExcludeInitialTransaction && item.replace(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, "") === CONST.IOU.OPTIMISTIC_TRANSACTION_ID) {
                return acc;
            }
            acc[item] = null;
            return acc;
        },
        {} as Record<string, null>,
    );
    return Onyx.multiSet(draftTransactionsSet);
    

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

    N/A

  4. lorretheboy commented on Aug 28, 2025

    @lorretheboy
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-09-02 15:49:20 UTC.

    Proposal

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

    Waypoints are not cleared after relaunching app

    What is the root cause of that problem?

    The issue was caused by the Onyx.connect() callback in for allTransactionDrafts not being executed until the code is actually imported. When removeDraftTransactions() was called during app startup, the allTransactionDrafts variable was still empty because the Onyx.connect() callback hadn't been triggered yet.

    let allTransactionDrafts: OnyxCollection<Transaction> = {};
    Onyx.connect({
    key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
    waitForCollectionCallback: true,
    callback: (value) => {
    allTransactionDrafts = value ?? {};
    },
    });

    So that this function is not working

    function removeDraftTransactions(shouldExcludeInitialTransaction = false) {

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

    We should fix the problematic function which is removeDraftTransactions. If no draft transactions in memory (likely due to inline require), we should use Onyx.connectWithoutView to get the current state from storage

    By doing this way, we can make sure all the place that trigger removeDraftTransactions would work as expected

        if (!draftTransactions.length || draftTransactions.length === 0) {
            return new Promise<void>((resolve) => {
                const conn = Onyx.connectWithoutView({
                    key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
                    waitForCollectionCallback: true,
                    callback: (draftTransactionCollection) => {
                        Onyx.disconnect(conn);
    
                        if (!draftTransactionCollection) {
                            resolve();
                            return;
                        }
    
                        const draftTransactionsSet = Object.keys(draftTransactionCollection).reduce(
                            (acc, key) => {
                                if (shouldExcludeInitialTransaction && key.replace(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, '') === CONST.IOU.OPTIMISTIC_TRANSACTION_ID) {
                                    return acc;
                                }
                                acc[key] = null;
                                return acc;
                            },
                            {} as Record<string, null>,
                        );
                        Onyx.multiSet(draftTransactionsSet).then(() => resolve());
                    },
                });
            });
        }

    Note: We can add new prop in removeDraftTransactions to only use connectWithoutView for the clear draft txn data in App.tsx

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

    NA

    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
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 2, 2025
  6. melvin-bot commented on Sep 2, 2025

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 2, 2025
  8. melvin-bot commented on Sep 2, 2025

    @melvin-bot

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

  9. brunovjk commented on Sep 2, 2025

    @brunovjk
    Contributor

    Thank you all for the proposals.
    @bernhardoj — you correctly identified the root cause, but I think your solution complicates the API surface and risking missed callers of startMoneyRequest or clearMoneyRequest. Thanks for the effort.

    I prefer the fix that refreshes draft transactions from storage using Onyx.connectWithoutView before clearing them.

    I think we can go with @lorretheboy's proposal

    🎀 👀 🎀 C+ reviewed

  10. 39 remaining items

  11. lorretheboy commented on Sep 14, 2025

    @lorretheboy
    Contributor

    @brunovjk I think we can ping QA to re-verify this bug again to see if it is still reproducible

  12. brunovjk commented on Sep 15, 2025

    @brunovjk
    Contributor

    @greg-schroeder or @Julesssss can you help us retest this issue? Thank you :D

  13. greg-schroeder commented on Sep 15, 2025

    @greg-schroeder
    Contributor
  14. brunovjk commented on Sep 15, 2025

    @brunovjk
    Contributor

    Thank you.

  15. greg-schroeder commented on Sep 15, 2025

    @greg-schroeder
    Contributor

    Seems this was resolved after all

  16. greg-schroeder commented on Sep 15, 2025

    @greg-schroeder
    Contributor

    Hmm. We need to figure out how to handle payment for this issue. Timeline:

    • Proposal made by @lorretheboy
    • Proposal reviewed by @brunovjk and assignment confirmed by @Julesssss
    • This PR is created and reviewed
    • PR is reverted due to regression
    • No new PR is created due to the issue being resolved elsewhere

    I think typically we still pay out issues even if they were "magically" fixed somewhere else if a contributor makes a proposal and writes code that's reviewed by a C+. However, this one resulted in a regression and was reverted anyway. Confirming with the team how to handle: https://expensify.slack.com/archives/C01SKUP7QR0/p1757942350600449

  17. greg-schroeder commented on Sep 15, 2025

    @greg-schroeder
    Contributor

    Let's go with $125 here

  18. greg-schroeder commented on Sep 15, 2025

    @greg-schroeder
    Contributor

    Sent updated offer to @lorretheboy

  19. lorretheboy commented on Sep 15, 2025

    @lorretheboy
    Contributor

    Approved it. Thanks @greg-schroeder

  20. greg-schroeder commented on Sep 15, 2025

    @greg-schroeder
    Contributor

    Payment summary:

    Contributor: @lorretheboy - $125 - Upwork
    C+: @brunovjk - $125 - ND manual request

  21. brunovjk commented on Sep 15, 2025

    @brunovjk
    Contributor

    Payment summary:

    Contributor: @lorretheboy - $125 - Upwork C+: @brunovjk - $125 - ND manual request

    Requested, thank you @greg-schroeder

  22. Julesssss commented on Sep 15, 2025

    @Julesssss
    Contributor

    Thanks Greg, I agree

  23. trjExpensify commented on Sep 15, 2025

    @trjExpensify
    Contributor

    approved $125 for @brunovjk. 👍

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.ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions