-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOLD for payment 2023-12-12] [$500] Distance – Inconsistency when editing waypoints #30290
Comments
Triggered auto assignment to @jliexpensify ( |
Job added to Upwork: https://www.upwork.com/jobs/~014a1428f6ef24d6ec |
Bug0 Triage Checklist (Main S/O)
|
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel ( |
Proposal by: @paultsimura ProposalPlease re-state the problem that we are trying to solve in this issue.When the distance request is modified: added, removed waypoint, and manually changed amount, it's reverted, and the removed waypoint is back. What is the root cause of that problem?When executing the App/src/libs/TransactionUtils.ts Lines 148 to 151 in b1ae0c2
Let's take a look at what happens when we remove one waypoint. The simple merge operation for the following object: {
"comment": {
"type": "customUnit",
"customUnit": {
"name": "Distance"
},
"waypoints": {
"waypoint0": { wp-0 },
"waypoint1": { wp-1 },
"waypoint2": { wp-2 }
}
}
} To the following object: {
"comment": {
"type": "customUnit",
"customUnit": {
"name": "Distance"
},
"waypoints": {
"waypoint0": { wp-0 },
"waypoint1": { wp-1 },
}
}
} ...will result in the same as pre-merge: {
"comment": {
"type": "customUnit",
"customUnit": {
"name": "Distance"
},
"waypoints": {
"waypoint0": { wp-0 },
"waypoint1": { wp-1 },
"waypoint2": { wp-2 }
}
}
} This is because the What changes do you think we should make in order to solve the problem?We should explicitly mark the deleted waypoints as function getReplacementWaypoints(transaction: Transaction, updatedWaypoints: WaypointCollection): WaypointCollection {
const existingWaypoints = getWaypoints(transaction) ?? {};
if (Object.keys(updatedWaypoints).length >= Object.keys(existingWaypoints).length) {
return updatedWaypoints;
}
return lodashReduce(existingWaypoints, (result, value, key) => ({
...result,
// Explicitly set the non-existing waypoints to null so that Onyx can remove them
[key]: updatedWaypoints[key] ?? null,
}), {});
} Second, use it here when building the updated transaction: if (Object.hasOwn(transactionChanges, 'waypoints')) {
- updatedTransaction.modifiedWaypoints = transactionChanges.waypoints;
+ updatedTransaction.modifiedWaypoints = getReplacementWaypoints(updatedTransaction, transactionChanges.waypoints!!);
shouldStopSmartscan = true;
} Third, we are also passing these waypoints to MapBox on the API call. We pass them as a stringified JSON, and there we should remove the null-ish waypoints: Line 697 in 3b86da6
We should use the following: waypoints: JSON.stringify(TransactionUtils.getValidWaypoints(transactionDetails.waypoints, true)), Similar to what we do in the Line 649 in 3b86da6
Result:Screen.Recording.2023-10-20.at.11.23.52.movWhat alternative solutions did you explore? (Optional)Alternatively, we can only modify the let newTransaction: Transaction = {
...transaction,
comment: {
...transaction.comment,
waypoints: reIndexedWaypoints,
},
modifiedWaypoints: reIndexedWaypoints
}; App/src/libs/actions/Transaction.ts Lines 125 to 134 in 01016dc
This solution is simpler and will have the same effect, but I'm not sure if we are OK with modifying the modifiedWaypoints field before the actual API call – would appreciate C+ input on this.
|
ProposalPlease re-state the problem that we are trying to solve in this issue.Distance – Inconsistency when editing waypoints What is the root cause of that problem?For example, on ONYX we have:
When remove a waypoint we will update waypoints field like this
As how ONYX.merge work, the result will be
This problem happens with transaction.modifiedWaypoints that causes this bug What changes do you think we should make in order to solve the problem?Note that: the same problem doesn't happen with transaction.comment.waypoint field because we are using SET method instead of MERGE method App/src/libs/actions/Transaction.ts Line 154 in cd3c863
So I suggest 2 solutions for this bug, for consistency we need to confirm which solution we should come up with and then using that solution in both places removeWaypoint and getUpdatedTransaction:
Then using getValidWaypoints function to remove null value when calling API What alternative solutions did you explore? (Optional) |
@DylanDylann that's basically 1:1 my proposal, just rephrased, isn't it? |
@paultsimura There are some differences between 2 proposals:
|
This is exactly what I suggest as an alternative solution 🙂 |
@paultsimura in your alternative solution, you suggest update modifiedWaypoints in removeWayPoint function. My proposal suggest using SET method instead of MERGE method for updated transaction in optimistic data. It is different totally |
Bump @Santhosh-Sellavel for reviews please! Also, I did some research and we should allow for editing distance requests, so this is a bug. |
Bump @Santhosh-Sellavel for reviews! |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
On my list today |
Did some investigation today, still need to dig more. Will post an review update tomorrow! |
@Santhosh-Sellavel any updates? |
Sorry no update yet. Will post update before monday |
@jliexpensify @Santhosh-Sellavel this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks! |
@jliexpensify, @Santhosh-Sellavel Whoops! This issue is 2 days overdue. Let's get this updated quick! |
@rushatgabhane @situchan what's the verdict here? @neil-marcellini - is there a need for you to also weigh in? |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
brought up a discussion here https://expensify.slack.com/archives/C01GTK53T8Q/p1702656464396679 about potentially reverting #31340 since it's caused a couple of blockers, please chime in there. |
okay to recap the thread, we are going to revert #31340. Tim and Neil are still discussing alternative solutions to solve this GH though in the thread so feel free to chime in there. |
Thanks Bondy! I'll hold on the conclusion of that thread, but I'm also OOO from the 19th - 28th so will handle payments after then. |
@paultsimura thank you for the detailed explaination |
According to this thread, we should put this issue on hold until #28358 is done |
This issue has not been updated in over 15 days. @neil-marcellini, @rushatgabhane, @jliexpensify, @DylanDylann eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
Still on hold, right @paultsimura ? |
Yes, the big 1:1:1 refactoring is currently in active development mode |
@neil-marcellini, @rushatgabhane, @jliexpensify, @DylanDylann, this Monthly task hasn't been acted upon in 6 weeks; closing. If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead. |
The refactor completed 3 days ago, so we can take this off hold finally |
Wow, old issue! Are @DylanDylann and @rushatgabhane eligible for payment here? |
No, the solution here was reverted as ot caused multiple regressions. After the revert, the issue was held for the 1:1:1 refactor for a second try. |
Thank you for confirming! @neil-marcellini can we close this then, since there are no payments required? |
Closing this as no payments required. |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 1.3.90.1
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: @paultsimura
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1698158967101059
Action Performed:
Expected Result:
After the amount is modified manually, it should persist.
Actual Result:
The modified amount is reverted to the previous value
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Android: Native
Android: mWeb Chrome
Screen.Recording.2023-10-24.at.18.11.20.mov
iOS: Native
RPReplay_Final1698162445.MP4
iOS: mWeb Safari
RPReplay_Final1698162580.MP4
MacOS: Chrome / Safari
Screen.Recording.2023-10-24.at.16.55.23.mp4
Recording.5141.mp4
MacOS: Desktop
Screen.Recording.2023-10-24.at.16.55.23.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: