You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-01-04] [$500] Distance - Description is not saved when created offline and description edit message becomes amount #31142
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor
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
Navigate to staging.new.expensify.com
Go offline
Go to workspace chat > + > Distance
Create a Distance request that has a description
Go to Distance request details page
Click on Description and add a description again
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?
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
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:
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.
This happens because we don't do a deep merge here:
// 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
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:
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor
Activity
[-]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[/+]melvin-bot commentedon Nov 9, 2023
Job added to Upwork: https://www.upwork.com/jobs/~018d38eec8fb70c3c2
melvin-bot commentedon Nov 9, 2023
Triggered auto assignment to @dylanexpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 9, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Nov 9, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @0xmiroslav (
External)esh-g commentedon Nov 9, 2023
Proposal
Please re-state the problem
Distance - Description is not saved when created offline and description edit message becomes amount
Root cause
Basically the
existingTransactionobject has properties which are also objects for exampletransaction.comment.commentto get the actual comment text.This is how a transaction object can look:
Now the
optimisticTransactionhas the property for the comment text that user has entered while theexistingTransactionhas the waypoints. This means that thecommentproperty inexistingTransactionoverwrites the property ofoptimisticTransactionwhich in-turn preserves the waypoints but deletes the user comment.This happens because we don't do a deep merge here:
App/src/libs/actions/IOU.js
Lines 511 to 522 in 7b78542
What changes should be made to fix this?
We just do a deep merge at the fore-mentioned code:
import merge function from lodash
esh-g commentedon Nov 9, 2023
@tgolen Seems like it is causing problems... 😅
tgolen commentedon Nov 9, 2023
There is a first time for everything! Thanks for looking into it.
0xmiroslav commentedon Nov 9, 2023
@esh-g why does it happen only on distance request? I am not able to reproduce on manual request.
69 remaining items
melvin-bot commentedon Dec 28, 2023
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:
esh-g commentedon Jan 8, 2024
gentle bump @dylanexpensify
dylanexpensify commentedon Jan 9, 2024
Payment Summary:
Please apply!
0xmiroslav commentedon Jan 9, 2024
Automatic offers were already sent by Melvin
dylanexpensify commentedon Jan 9, 2024
Just paid! Had to post summary for good measure!
dylanexpensify commentedon Jan 9, 2024
@0xmiroslav mind completing checklist?
0xmiroslav commentedon Jan 9, 2024
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.
melvin-bot commentedon Jan 12, 2024
@arosiclair, @dylanexpensify, @esh-g, @0xmiroslav Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!