Open izarutskaya opened 2 months ago
Triggered auto assignment to @kadiealexander (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
Edited by proposal-police: This proposal was edited at 2024-09-02 12:19:32 UTC.
Distance - Unable to save distance when Start and Stop waypoints are valid address
hasRouteError
& isEditing
is true, we can set the optimisticWaypoints
value to transactionBackup/transaction?.modifiedWaypoints
. This will make sure that we show the invalid waypoints when we have a route error.const [optimisticWaypoints, setOptimisticWaypoints] = useState<WaypointCollection | null>(hasRouteError && isEditing ? transactionBackup?.modifiedWaypoints ?? null : null);
We can manually clear the errors when the MoneyRequestView
component mounts for the first time and we have a route error.
We can use the same functions to clear the error like: https://github.com/Expensify/App/blob/7e0bf3dbd64546e3e1f47935bf367d57a23a60b1/src/components/ReportActionItem/MoneyRequestView.tsx#L486-L487
Or we can do that in IOURequestStepDistance
. We can check if there is no error except the route error and then we can clear the errors.
Or we can clear the errors when the MoneyRequestView
is unmounted and we have a route error.
Job added to Upwork: https://www.upwork.com/jobs/~013c32d2d6ff5c2253
Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane (External
)
Nothing happens after clicking Save button when Start and Stop waypoints are valid.
After we go to the expense report or transaction thread report again, the transaction data is returned from BE that will reset the waypoint data of the transaction but the transaction error isn't cleared. Then we cannot save the distance without changing it.
In MoneyRequestView
, we can create a useEffect
that will clear the route error if hasRoute
is true
and the route transaction error still exists. That will ensure that the route error is only cleared when the route is re-fetched because we can have a case after the waypoint error appears user can offline and open the expense report/transaction thread report again (in this case, the waypoint isn't re-fetched and we don't want to clear the error). We can create a new util to only clear the route error or re-use Transaction.clearError
function.
useEffect(() => {
if (!transaction?.errorFields?.route || !hasRoute) {
return;
}
Transaction.clearRouteError(transaction.transactionID);
}, [hasRoute, transaction?.errorFields?.route, transaction?.transactionID]);
NA
@Krishna2323 @nkdengineer Looks like the issue is not reproducible any longer.
I cannot reproduce the issue.
@sobitneupane I can still able to reproduce this bug on the latest main.
https://github.com/user-attachments/assets/dc4aef04-a034-4ca6-9f47-5a679437bacd
Thanks @nkdengineer
I don't think we should remove the error. The invalid waypoint error will be shown in the transaction thread, and when the user opens the transaction, they won't find any error. We should display the error alongside the invalid addresses.
Thanks for the proposal @Krishna2323
const hasRouteError = !!transaction?.errorFields?.route const [optimisticWaypoints, setOptimisticWaypoints] = useState<WaypointCollection | null>(hasRouteError && isEditing ? transactionBackup?.modifiedWaypoints ?? null : null);
What are the different cases that can lead to a route error (apart from an invalid waypoint)? I can think of three: duplicate waypoints, empty waypoints, no route found
I’d like to gauge first whether those cases would be affected by the proposed change.
@sobitneupane, these are the other two errors.
What are the different cases that can lead to a route error (apart from an invalid waypoint)?
I can think of these two cases:
const hasRouteError = !!transaction?.errorFields?.route;
const isEditing = action === CONST.IOU.ACTION.EDIT;
const [optimisticWaypoints, setOptimisticWaypoints] = useState<WaypointCollection | null>(hasRouteError && isEditing ? transactionBackup?.modifiedWaypoints ?? null : null);
@Krishna2323 It does not solve the issue. I can still reproduce the issue.
https://github.com/user-attachments/assets/bedd7178-b133-4e53-a118-cb3f7cfde7af
I don't think we should remove the error. The invalid waypoint error will be shown in the transaction thread, and when the user opens the transaction, they won't find any error. We should display the error alongside the invalid addresses.
@sobitneupane The problem here is after we re-open the expense report, BE will return the data that overrides the invalid waypoint.
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@sobitneupane, @kadiealexander Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
The problem here is after we re-open the expense report, BE will return the data that overrides the invalid waypoint.
@nkdengineer I got it. If we don't show an error, the user might think their change was successful.
@sobitneupane @kadiealexander 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!
@sobitneupane, @kadiealexander Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Waiting for proposal.
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
Edited by proposal-police: This proposal was edited at 2024-09-20 06:08:06 UTC.
Distance - Unable to save distance when Start and Stop waypoints are valid addresses
Server send error and this check will be true:
We should re-validate the route on the initialMount, since the error remains, but waypoints has corrected from api failureData
In src/hooks/useFetchRoute.ts
add new state isInitialMount
with default to true
const [isInitialMount, setIsInitialMount] = useState(true);
And change shouldFetchRoute
logic
To
const shouldFetchRoute = (isDistanceRequest && (isRouteAbsentWithoutErrors || haveValidatedWaypointsChanged || isInitialMount) && !isLoadingRoute && Object.keys(validatedWaypoints).length > 1);
or only initial re-validate if it has route error
const shouldFetchRoute = (isDistanceRequest && (isRouteAbsentWithoutErrors || haveValidatedWaypointsChanged || (isInitialMount && hasRouteError)) && !isLoadingRoute && Object.keys(validatedWaypoints).length > 1);
And we need to skip hasRouteError validation when submitWaypoints in offline mode, because we allow unvalidated waypoints while offline, without this, the save button will be blocked in offline mode: src/pages/iou/request/step/IOURequestStepDistance.tsx
const submitWaypoints = useCallback(() => {
// If there is any error or loading state, don't let user go to next page.
if ((duplicateWaypointsError || atLeastTwoDifferentWaypointsError || (hasRouteError && !isOffline) || isLoadingRoute || (!isEditing && isLoading))) {
And remove transactionBackup?.pendingFields?.waypoints
here so it can contain values for the case in this issue
We don't really need that check, related PR https://github.com/Expensify/App/pull/51519 still working properly without that.
Provide X button in waypoint editor, so user can manually clear the errors and able to save the editor
@sobitneupane, @kadiealexander Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Thanks for the proposal @wildan-m Can you please explain the output after the change?
And we need to skip hasRouteError validation when submitWaypoints in offline mode: src/pages/iou/request/step/IOURequestStepDistance.tsx
Can you please add reasoning for this change?
In my understanding, the issue occurs because, instead of displaying the invalid addresses when opening the distance page, we are showing a previous valid route along with errors from the invalid route, which leads to the problem. I believe this should be the expected output.
In my understanding, the issue occurs because, instead of displaying the invalid addresses when opening the distance page, we are showing a previous valid route along with errors from the invalid route, which leads to the problem. I believe https://github.com/Expensify/App/issues/48401#issuecomment-2338167468 should be the expected output.
That's true, but when we call the API, if there is error the failedData
section of the API will restore the value to its previous correct value.
There is no guarantee that the user will re-open that distance request, restoring it to previous correct value is better than keeping the wrong values.
Consider this scenario: If we keep the wrong values, then user clicking the X button to clear the error, which function will fix the wrong values? assume the user will not re-open the distance page and stay on its parent report.
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@sobitneupane, @kadiealexander Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@kadiealexander When submitting a distance expense(offline) with invalid waypoints (random strings for Start and Stop addresses), an error is shown and the invalid waypoints are optimistically saved. However, after coming back online and returning to the transaction thread shows the valid waypoints, as fetched from the API, instead of the invalid ones. The issue arises because the transaction details are re-fetched, which updates the waypoints to valid ones but retains the error message from the original invalid waypoints. This creates a mismatch where valid waypoints are displayed, but the error still reflects the previous invalid input. The question is: should we display the invalid waypoints along with the error message, or should we show the valid waypoints returned by the API and remove the error?
Started discussion in slack: https://expensify.slack.com/archives/C01GTK53T8Q/p1727685264166239
@sobitneupane @kadiealexander this issue is now 4 weeks old, please consider:
Thanks!
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@sobitneupane in my opinion, we should show the valid waypoints returned by the API and remove the error.
@sobitneupane, @kadiealexander Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Thanks for the input, @kadiealexander.
I will re-review the proposals, taking this comment into account as the expected output.
Thanks for the proposal, @wildan-m
As suggested here, we should remove the error as well.
Or we can do that in IOURequestStepDistance. We can check if there is no error except the route error and then we can clear the errors.
@Krishna2323 Can you please share more details on how you intend to implement the plan.
As suggested https://github.com/Expensify/App/issues/48401#issuecomment-2387658858, we should remove the error as well.
@sobitneupane my solution will remove the error once the server validated the waypoints.
Why the error restored when we navigate back? that's because we aren't updating the transactionBackup waypoints data when we are online so error persists in backup and will be restored when we navigate back from waypoint editor. This navigate back issue will be resolved after the PR in this issue merged https://github.com/Expensify/App/issues/48630
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@wildan-m In that case we should wait for https://github.com/Expensify/App/issues/48630 to get resolved.
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@sobitneupane, @kadiealexander Eep! 4 days overdue now. Issues have feelings too...
@sobitneupane, @kadiealexander 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
Still waiting on https://github.com/Expensify/App/issues/48630
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@sobitneupane, @kadiealexander Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@sobitneupane, I've tested it and the error message removed as expected.
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: v9.0.27-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: https://expensify.testrail.io/index.php?/tests/view/4908819 Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com Logs: https://stackoverflow.com/c/expensify/questions/4856 Issue reported by: Applause-Internal team
Action Performed:
Expected Result:
The distance will be saved because Start and Stop waypoints are valid.
Actual Result:
Nothing happens after clicking Save button when Start and Stop waypoints are valid.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
https://github.com/user-attachments/assets/bddd22db-5784-490e-8c3f-076b2da15e1a
View all open jobs on GitHub
Upwork Automation - Do Not Edit