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-03-06] [$500] [MEDIUM] Distance - Map doesn't load and TBD remains when creating request and editing amount offline #32263
Version Number: v1.4.5-7 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 Tean Slack conversation: @
Action Performed:
Navigate to staging.new.expensify.com
Go offline.
Go to workspace chat > + > Request money.
Create a distance request.
Open distance request details page > Amount.
Enter amount and save it.
Go online.
Expected Result:
The map will load and the fields with TBD will load data when the network connection is regained.
Actual Result:
The map never loads and all the details remain TBD.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
changed the title [-]Distance - Map doesn't load and TBD remains when creating request and editing amount offline[/-][+][$500] Distance - Map doesn't load and TBD remains when creating request and editing amount offline[/+]on Nov 30, 2023
As a result, when coming back online, both operations execute, and the "pendingFields": null is ignored (I believe, this is an in-Onyx bug, probably because the operations with null get stacked incorrectly), and the optimistically added "waypoints": "add" is not removed on successful response.
What changes do you think we should make in order to solve the problem?
We should reset the pendingFields while creating a money request not fully: pendingFields: null, but only the pending fields which were set optimistically, similar to the editing scenario – in our case, it would look like this:
We should also use if (!transaction.isLoading) instead of if (!Object.hasOwn(transaction?.pendingFields ?? {}, 'waypoints')) here, otherwise the map will be replaced with the pending receipt while the waypoints are being added.
Please re-state the problem that we are trying to solve in this issue.
Map doesn't load and TBD remains when creating request and editing amount offline
This is bug video
bug.mp4
I see we have 2 bugs:
When creating distance request offline the amount field will be TBD. If we click the amount field and edit another number, the amount field will be TBD (can't edit amount field when offline and there is pending waypoint)
After editing amount field and go online, the map doesn't load and the amount field still be TBD
We are setting amount field to TBD if pendingFields.waypoints is valuable
For the bug 2, when creating distance request in successData we set pendingFields: null to reset pendingFields.waypoints. When editing distance request in success data we set
pendingFields {
amount: null
currency: null
But after 2 APIs success, the pending field of creating distance request isn't merged to ONYX so pendingFields.waypoints still be valuable. It seems It is ONYX problem.
What changes do you think we should make in order to solve the problem?
For bug 1, I suggest 2 solution:
Because we always display TBD if there is any pending waypoint, we also need to disable amount field and don't allow user editing this field if there is any pending waypoint
We still allow user edit amount and display modifiedAmount if !formattedTransactionAmount || hasPendingWaypoints. If modifiedAmount is empty we still display TBD as old logic
For the bug 2, I suggest 2 solution:
When creating new distance request we only need set pendingAction and shouldn't set pendingField.waypoints It is redundant
I am not sure why we add pendingField in saveWaypoint function (this function only merge data to ONYX, not send API). Noe Note that, pendingField only be added in optimisticaData (apply before sending API) and It is re-set in successData and FailureData
In successData of create distance request we should reset pending field like
changed the title [-][$500] [MEDIUM] Distance - Map doesn't load and TBD remains when creating request and editing amount offline[/-][+][HOLD for payment 2024-03-06] [$500] [MEDIUM] Distance - Map doesn't load and TBD remains when creating request and editing amount offline[/+]on Mar 2, 2024
Activity
[-]Distance - Map doesn't load and TBD remains when creating request and editing amount offline[/-][+][$500] Distance - Map doesn't load and TBD remains when creating request and editing amount offline[/+]melvin-bot commentedon Nov 30, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01a40cd0507a4b7824
melvin-bot commentedon Nov 30, 2023
Triggered auto assignment to @greg-schroeder (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 30, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Nov 30, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (
External)dukenv0307 commentedon Nov 30, 2023
@izarutskaya Can you please update the video of this issue.
paultsimura commentedon Nov 30, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
When creating & modifying a Distance request offline, the TBD state is stuck.
What is the root cause of that problem?
There is a race condition of onSuccess update of the transaction's
pendingFields.When creating the request, the
successDatacontains the following update for the transaction:App/src/libs/actions/IOU.js
Line 259 in a56c5cb
And when modifying the amount:
App/src/libs/actions/IOU.js
Line 799 in a56c5cb
As a result, when coming back online, both operations execute, and the
"pendingFields": nullis ignored (I believe, this is an in-Onyx bug, probably because the operations withnullget stacked incorrectly), and the optimistically added"waypoints": "add"is not removed on successful response.What changes do you think we should make in order to solve the problem?
We should reset the
pendingFieldswhile creating a money request not fully:pendingFields: null, but only the pending fields which were set optimistically, similar to the editing scenario – in our case, it would look like this:To do this, make the following changes:
App/src/libs/actions/IOU.js
Lines 254 to 261 in a56c5cb
What alternative solutions did you explore? (Optional)
We set the
transaction.isLoadingwhen modifying the waypoints of the distance request here:App/src/libs/actions/IOU.js
Lines 757 to 766 in cd9cd57
And we handle this state in other places, like here:
App/src/components/DistanceRequest/index.js
Line 84 in 19c8e25
We should set this
isLoadingstate not only while editing, but when creating the Distance request as well.We shouldn't rely on the
hasPendingWaypoints, but rather thetransaction.isLoadingas well inMoneyRequestViewto display TBD:App/src/components/ReportActionItem/MoneyRequestView.js
Line 102 in 12eb47f
We should also use
if (!transaction.isLoading)instead ofif (!Object.hasOwn(transaction?.pendingFields ?? {}, 'waypoints'))here, otherwise the map will be replaced with the pending receipt while the waypoints are being added.App/src/libs/ReceiptUtils.ts
Line 40 in 61c8b11
DylanDylann commentedon Dec 1, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Map doesn't load and TBD remains when creating request and editing amount offline
This is bug video
bug.mp4
I see we have 2 bugs:
What is the root cause of that problem?
For the bug 1
App/src/components/ReportActionItem/MoneyRequestView.js
Lines 103 to 105 in dad6391
We are setting amount field to TBD if
pendingFields.waypointsis valuableFor the bug 2, when creating distance request in successData we set
pendingFields: nullto resetpendingFields.waypoints. When editing distance request in success data we setBut after 2 APIs success, the pending field of creating distance request isn't merged to ONYX so
pendingFields.waypointsstill be valuable. It seems It is ONYX problem.What changes do you think we should make in order to solve the problem?
For bug 1, I suggest 2 solution:
!formattedTransactionAmount || hasPendingWaypoints. If modifiedAmount is empty we still display TBD as old logicFor the bug 2, I suggest 2 solution:
pendingField.waypointsIt is redundantApp/src/libs/actions/Transaction.ts
Lines 61 to 63 in 05ae4c4
I am not sure why we add pendingField in saveWaypoint function (this function only merge data to ONYX, not send API). Noe Note that, pendingField only be added in optimisticaData (apply before sending API) and It is re-set in successData and FailureData
53 remaining items
[-][$500] [MEDIUM] Distance - Map doesn't load and TBD remains when creating request and editing amount offline[/-][+][HOLD for payment 2024-03-06] [$500] [MEDIUM] Distance - Map doesn't load and TBD remains when creating request and editing amount offline[/+]greg-schroeder commentedon Mar 7, 2024
Hmm. The upwork job was closed for some reason, even though there was recent activity. I don't know. I'll probably have to create a new one...
paultsimura commentedon Mar 7, 2024
@greg-schroeder it's weird because the offer is still active for me on Upwork 🤔
greg-schroeder commentedon Mar 8, 2024
Apologies, I was out yesterday, but I'll generate a new job today and get this done
greg-schroeder commentedon Mar 9, 2024
Doing
greg-schroeder commentedon Mar 9, 2024
@paultsimura paid! @Ollyws can you accept the offer we sent you? I'll pay you as soon as you accept
Ollyws commentedon Mar 9, 2024
Accepted, thanks!
greg-schroeder commentedon Mar 9, 2024
cool, paid