Skip to content

[HOLD for payment 2024-01-04] [$500] Distance - Description is not saved when created offline and description edit message becomes amount #31142

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.3.97-2
Reproducible in staging?: Y
Reproducible in production?: Y
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: Applause - Internal Team
Slack conversation:

Action Performed:

Precondition: Have some saved address offline

  1. Navigate to staging.new.expensify.com
  2. Go offline
  3. Go to workspace chat > + > Distance
  4. Create a Distance request that has a description
  5. Go to Distance request details page
  6. Click on Description and add a description again
  7. Go online

Expected Result:

In Step 5, the description which is added in Step 4 will appear in the distance details page
In Step 7, when the request is created, the system message for 'set a description to' will not change

Actual Result:

In Step 5, the description which is added in Step 4 is not saved
In Step 7, when the request is created, the system message for 'set a description to' changes to 'changed the amount to 0.00'

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

Bug6270188_1699547144451.bandicam_2023-11-09_23-57-04-982.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~018d38eec8fb70c3c2
  • Upwork Job ID: 1722653765286424576
  • Last Price Increase: 2023-11-09
  • Automatic offers:
    • 0xmiroslav | Reviewer | 27953114
    • esh-g | Contributor | 27953116

Activity

  1. added
    External
    Daily
    Bug
    on Nov 9, 2023
  2. changed the title [-]Distance - Description is not saved when created offline and description edit message becomes amount[/-] [+][$500] Distance - Description is not saved when created offline and description edit message becomes amount[/+] on Nov 9, 2023
  3. melvin-bot commented on Nov 9, 2023

    @melvin-bot
  4. melvin-bot commented on Nov 9, 2023

    @melvin-bot

    Triggered auto assignment to @dylanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  5. added
    Help Wanted
    on Nov 9, 2023
  6. melvin-bot commented on Nov 9, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Nov 9, 2023

    @melvin-bot

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

  8. esh-g commented on Nov 9, 2023

    @esh-g
    Contributor

    Proposal

    Please re-state the problem

    Distance - Description is not saved when created offline and description edit message becomes amount

    Root cause

    Basically the existingTransaction object has properties which are also objects for example transaction.comment.comment to get the actual comment text.
    This is how a transaction object can look:

    type Transaction = {
        amount: number;
        billable: boolean;
        category: string;
        comment: {
          comment?: string;
          waypoints?: WaypointCollection;
          isLoading?: boolean;
          type?: string;
          customUnit?: Record<string, unknown>;
          source?: string;
          originalTransactionID?: string;
        };
        created: string;
    }

    Now the optimisticTransaction has the property for the comment text that user has entered while the existingTransaction has the waypoints. This means that the comment property in existingTransaction overwrites the property of optimisticTransaction which in-turn preserves the waypoints but deletes the user comment.

    Screenshot 2023-12-02 at 7 20 49 PM

    This happens because we don't do a deep merge here:

    App/src/libs/actions/IOU.js

    Lines 511 to 522 in 7b78542

    // If there is an existing transaction (which is the case for distance requests), then the data from the existing transaction
    // needs to be manually merged into the optimistic transaction. This is because buildOnyxDataForMoneyRequest() uses `Onyx.set()` for the transaction
    // data. This is a big can of worms to change it to `Onyx.merge()` as explored in https://expensify.slack.com/archives/C05DWUDHVK7/p1692139468252109.
    // I want to clean this up at some point, but it's possible this will live in the code for a while so I've created https://github.com/Expensify/App/issues/25417
    // to remind me to do this.
    const existingTransaction = existingTransactionID && TransactionUtils.getTransaction(existingTransactionID);
    if (existingTransaction) {
    optimisticTransaction = {
    ...optimisticTransaction,
    ...existingTransaction,
    };
    }

    What changes should be made to fix this?

    We just do a deep merge at the fore-mentioned code:

    if (existingTransaction) {
        optimisticTransaction = merge(optimisticTransaction, existingTransaction),
    }

    import merge function from lodash

  9. esh-g commented on Nov 9, 2023

    @esh-g
    Contributor

    These are still all in the code, but it's not causing any problems, so I am just going to close this since I haven't had any chance to look into it.

    @tgolen Seems like it is causing problems... 😅

  10. tgolen commented on Nov 9, 2023

    @tgolen
    Contributor

    There is a first time for everything! Thanks for looking into it.

  11. 0xmiroslav commented on Nov 9, 2023

    @0xmiroslav
    Contributor

    @esh-g why does it happen only on distance request? I am not able to reproduce on manual request.

  12. 69 remaining items

  13. melvin-bot commented on Dec 28, 2023

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

    • [@0xmiroslav] The PR that introduced the bug has been identified. Link to the PR:
    • [@0xmiroslav] 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:
    • [@0xmiroslav] 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:
    • [@0xmiroslav] Determine if we should create a regression test for this bug.
    • [@0xmiroslav] 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.
    • [@dylanexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  14. added
    Daily
    and removed
    Weekly
    on Jan 4, 2024
  15. esh-g commented on Jan 8, 2024

    @esh-g
    Contributor

    gentle bump @dylanexpensify

  16. dylanexpensify commented on Jan 9, 2024

    @dylanexpensify
    Contributor

    Payment Summary:

    Please apply!

  17. 0xmiroslav commented on Jan 9, 2024

    @0xmiroslav
    Contributor

    Automatic offers were already sent by Melvin

  18. dylanexpensify commented on Jan 9, 2024

    @dylanexpensify
    Contributor

    Just paid! Had to post summary for good measure!

  19. dylanexpensify commented on Jan 9, 2024

    @dylanexpensify
    Contributor

    @0xmiroslav mind completing checklist?

  20. 0xmiroslav commented on Jan 9, 2024

    @0xmiroslav
    Contributor

    We were already aware of the root cause and it was temporary solution.
    Now that this bug was caught, we fixed with permanent solution.

    As this was caught by Applause, we can skip regression test.

  21. melvin-bot commented on Jan 12, 2024

    @melvin-bot

    @arosiclair, @dylanexpensify, @esh-g, @0xmiroslav Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyEngineeringExternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions