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
[$500] Distance - Duplicate waypoint error message is not dimissed after closing distance editor #34999
BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2
Version Number: 1.4.30-0 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: App location access is disabled
Go to workspace chat
Create a distance request with A-B-A address
Navigate to request details page
Click Distance
Drag the waypoint so that it becomes A-A-B
Save the request
Exit the distance editor
Refresh the page
Click Distance
Expected Result:
The duplicate waypoint error message is dismissed
Actual Result:
The duplicate waypoint error message is not dismissed
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
changed the title [-]Distance - Duplicate waypoint error message is not dimissed after closing distance editor[/-][+][$500] Distance - Duplicate waypoint error message is not dimissed after closing distance editor[/+]on Jan 23, 2024
However, in this issue's scenario, we save the transaction (transactionWasSaved.current becomes true), but the changes are not persisted due to the route error. However, we still return early because the condition of transactionWasSaved.current is met, and therefore do not fully restore the transaction to its original state.
What changes do you think we should make in order to solve the problem?
We should add an extra check – early return only if the transaction was saved without a route error:
return()=>{// If the user cancels out of the modal without saving changes, then the original transaction// needs to be restored from the backup so that all changes are removed.if(transactionWasSaved.current&&!hasRouteError){return;}TransactionEdit.restoreOriginalTransactionFromBackup(transaction.transactionID);};
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
The error message regarding non-unique waypoints in a distance request feature persists even after a user refreshes the page. This indicates that the error state is not being reset as expected during a page reload.
What is the root cause of that problem?
The root cause of the error message persisting after a page refresh is perhaps due to the hasError state in the DistanceRequest component not being reset correctly. The state is initially set to false, but the code only explicitly resets it in a specific useEffect cleanup function tied to the transaction and transactionID dependencies. If this cleanup function doesn't trigger correctly on a page refresh - either because the component isn't unmounting/remounting properly, or the dependencies don't change as expected - then the hasError state remains true, causing the error message to persist. Additionally, the submitWaypoints function sets this error state under certain conditions, but without a corresponding reset mechanism that activates on page refresh, the error state is not cleared.
What changes do you think we should make in order to solve the problem?
Ensure hasError Resets on Page Refresh:
Modify the useEffect for transaction and transactionID to explicitly reset hasError not only when the component unmounts but also when it remounts, which typically happens on a page refresh. This can involve adding a condition to check if waypoints or relevant conditions have been reinitialized and reset hasError accordingly.
Review and Update submitWaypoints Logic:
Implement a mechanism in submitWaypoints to reset hasError when the conditions that initially set it to true no longer apply. This could involve adding a state update at the start of this function to reset the error state, or incorporating additional checks to ensure the state aligns with the current conditions.
Improve Waypoints Update Logic:
In updateWaypoints, add logic to reassess the error state whenever waypoints are successfully updated. This ensures that if the error condition related to waypoints is resolved, hasError is reset to false.
What alternative solutions did you explore? (Optional)
To validate we can add an extra check like, (_.keys(waypoints).length > 2 && _.size(validatedWaypoints) !== _.keys(waypoints).length) to check if the all waypoints are valid.
We already have done it inside IOURequestStepDistance:
📣 @tienifr 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Keep in mind: Code of Conduct | Contributing 📖
@JmillsExpensify@tgolen@alitoshmatov@tienifr 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!
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: No need
Determine if we should create a regression test for this bug. No need
BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2
Activity
[-]Distance - Duplicate waypoint error message is not dimissed after closing distance editor[/-][+][$500] Distance - Duplicate waypoint error message is not dimissed after closing distance editor[/+]melvin-bot commentedon Jan 23, 2024
Job added to Upwork: https://www.upwork.com/jobs/~018929236a56deb238
melvin-bot commentedon Jan 23, 2024
Triggered auto assignment to @JmillsExpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Jan 23, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @alitoshmatov (
External)lanitochka17 commentedon Jan 23, 2024
We think that this bug might be related to #wave6.
CC @greg-schroeder
paultsimura commentedon Jan 23, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
The "Duplicate waypoint" error remains between the "edit distance" page refreshes.
What is the root cause of that problem?
For the distance request, we use a hook that restores the transaction to the original one if it was not saved:
App/src/components/DistanceRequest/index.js
Lines 117 to 126 in 872eb17
However, in this issue's scenario, we save the transaction (
transactionWasSaved.currentbecomestrue), but the changes are not persisted due to the route error. However, we still return early because the condition oftransactionWasSaved.currentis met, and therefore do not fully restore the transaction to its original state.What changes do you think we should make in order to solve the problem?
We should add an extra check – early return only if the transaction was saved without a route error:
What alternative solutions did you explore? (Optional)
JordanLevy19 commentedon Jan 23, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
The error message regarding non-unique waypoints in a distance request feature persists even after a user refreshes the page. This indicates that the error state is not being reset as expected during a page reload.
What is the root cause of that problem?
The root cause of the error message persisting after a page refresh is perhaps due to the hasError state in the DistanceRequest component not being reset correctly. The state is initially set to false, but the code only explicitly resets it in a specific useEffect cleanup function tied to the transaction and transactionID dependencies. If this cleanup function doesn't trigger correctly on a page refresh - either because the component isn't unmounting/remounting properly, or the dependencies don't change as expected - then the hasError state remains true, causing the error message to persist. Additionally, the submitWaypoints function sets this error state under certain conditions, but without a corresponding reset mechanism that activates on page refresh, the error state is not cleared.
What changes do you think we should make in order to solve the problem?
Ensure hasError Resets on Page Refresh:
Modify the useEffect for transaction and transactionID to explicitly reset hasError not only when the component unmounts but also when it remounts, which typically happens on a page refresh. This can involve adding a condition to check if waypoints or relevant conditions have been reinitialized and reset hasError accordingly.
Review and Update submitWaypoints Logic:
Implement a mechanism in submitWaypoints to reset hasError when the conditions that initially set it to true no longer apply. This could involve adding a state update at the start of this function to reset the error state, or incorporating additional checks to ensure the state aligns with the current conditions.
Improve Waypoints Update Logic:
In updateWaypoints, add logic to reassess the error state whenever waypoints are successfully updated. This ensures that if the error condition related to waypoints is resolved, hasError is reset to false.
What alternative solutions did you explore? (Optional)
samilabud commentedon Jan 23, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Distance - waypoint error message is not dimissed after closing distance editor
What is the root cause of that problem?
We are using Onyx to store and persist errors inside the transaction object:
App/src/types/onyx/Transaction.ts
Line 60 in 0efabc2
Because of this when we got an error we going to keep it at least we save the waypoints again.
What changes do you think we should make in order to solve the problem?
We should clean the transaction errors when unmount the Distance request component inside the next line:
App/src/components/DistanceRequest/index.js
Line 117 in 0efabc2
The code result should be:
And the cleanTransactionErrors could be (inside of https://github.com/Expensify/App/blob/main/src/libs/actions/TransactionEdit.ts):
Result:
Distance.request.error.test.mp4
Krishna2323 commentedon Jan 24, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Distance - Duplicate waypoint error message is not dimissed after closing distance editor
What is the root cause of that problem?
We save the waypoints even if we have duplicates & thats why its been stored in ONYX and it persists after refresh.
What changes do you think we should make in order to solve the problem?
We should not save the waypoint if we have duplicates. We need to return from here:
App/src/components/DistanceRequest/index.js
Line 212 in 0efabc2
To validate we can add an extra check like,
(_.keys(waypoints).length > 2 && _.size(validatedWaypoints) !== _.keys(waypoints).length)to check if the all waypoints are valid.We already have done it inside
IOURequestStepDistance:App/src/pages/iou/request/step/IOURequestStepDistance.js
Lines 168 to 170 in 0efabc2
Result
28 remaining items
melvin-bot commentedon Feb 5, 2024
📣 @tienifr 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Keep in mind: Code of Conduct | Contributing 📖
melvin-bot commentedon Feb 6, 2024
@JmillsExpensify @tgolen @alitoshmatov @tienifr 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!
tienifr commentedon Mar 1, 2024
@JmillsExpensify PR hit production. Melvin is malfunctioning. Please add HOLD for payment label.
tienifr commentedon Mar 18, 2024
@JmillsExpensify Would you mind helping with payment here? Thanks
alitoshmatov commentedon Mar 26, 2024
@JmillsExpensify Bump
JmillsExpensify commentedon Mar 29, 2024
If you need something urgent please please reach out to me in Slack in our open source community or directly 1:1. Sorry for the delay!
JmillsExpensify commentedon Mar 29, 2024
Payment summary:
Also @alitoshmatov I don't believe I've seen a BZ checklist. Can you please complete one? Thank you.
JmillsExpensify commentedon Mar 29, 2024
All contributors have been paid out though please @alitoshmatov help with the BZ checklist before we can close this on out!
JmillsExpensify commentedon Apr 1, 2024
@alitoshmatov bump on the BZ checklist.
alitoshmatov commentedon Apr 1, 2024
cc: @JmillsExpensify
JmillsExpensify commentedon Apr 1, 2024
Great thanks so much! Given no regression test is required, I'll close the issue.