Skip to content
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-10-02] [$500] [Distance] - Wrong error is shown for maximum distance limitation even after deleting way point #27538

Closed
1 of 6 tasks
kbecciv opened this issue Sep 15, 2023 · 35 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Sep 15, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Click on FAB > Request money > Distance
  2. Click on start field and insert "Ethiopia "as the starting point
  3. Click on the finish field and insert "USA" as the finishing point
  4. Observe the error ".... maximum distance limit"
  5. Click on Add stop
  6. Insert the same waypoint as the finishing point, ie. "USA"
  7. Click on the starting point and delete the waypoint with "Ethiopia" as the starting point
  8. Observe the error

Expected Result:

The error should disappear or change to something related to the current issue at hand

Actual Result:

The error from the previous state persists and does not reset or disappear

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.70.5
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
Notes/Photos/Videos: Any additional supporting documentation

2023-09-14.11.28.21.mp4
Recording.4494.mp4

Expensify/Expensify Issue URL:
Issue reported by: @Nathan-Mulugeta
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694680351264939

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01fb0d667643024cc9
  • Upwork Job ID: 1702693403466088448
  • Last Price Increase: 2023-09-15
  • Automatic offers:
    • samh-nl | Contributor | 26743874
    • Nathan-Mulugeta | Reporter | 26743875
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 15, 2023
@melvin-bot melvin-bot bot changed the title [Distance] - Wrong error is shown for maximum distance limitation even after deleting way point [$500] [Distance] - Wrong error is shown for maximum distance limitation even after deleting way point Sep 15, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01fb0d667643024cc9

@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 15, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

Triggered auto assignment to @kevinksullivan (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (External)

@ahmedGaber93
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

[Distance request] - Wrong error is shown for maximum distance limitation even after deleting way point

What is the root cause of that problem?

There is no error handle for matched start and end point

What changes do you think we should make in order to solve the problem?

We need to handle error matched start and end point.

  1. in TransactionUtils.js, we will create a new method to check if start and end point is matched.
import uniqWith from "lodash/uniqWith";

function isStartAndFinishWaypointsIdentical(waypoints) {
    // filter waypoints by remove the empty and invalid waypoints
    const validWaypoints = _.filter(_.values(waypoints), (waypoint) => waypointHasValidAddress(waypoint));
    
    const uniqueWaypoints = uniqWith(validWaypoints, (a, b) => _.isEqual(a, b));
    // we can also use the below method to get the unique waypoints
    // const uniqueWaypoints = _.uniq(validWaypoints, false, "address");

    return validWaypoints.length > 1 && uniqueWaypoints.length === 1;
}
  1. use the above method in DistanceRequest.js
const hasIdenticalError = TransactionUtils.isStartAndFinishWaypointsIdentical(waypoints);
const hasError = hasIdenticalError || hasRouteError;
const errorMessage = hasIdenticalError ? ["errors.identicalError"] : ErrorUtils.getLatestErrorField(transaction, 'route');
  1. edit displaying the error.
{(hasError) && (
    <DotIndicatorMessage
        style={[styles.mh5, styles.mv3]}
        messages={errorMessage}
        type="error"
    />
)}               

What alternative solutions did you explore? (Optional)

N/A

@samh-nl
Copy link
Contributor

samh-nl commented Sep 15, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Wrong error is shown for maximum distance limitation even after deleting way point

What is the root cause of that problem?

We only fetch the route if there are > 1 validated waypoints, which would cause the error to reset and update.

const shouldFetchRoute = (!doesRouteExist || haveWaypointsChanged) && !isLoadingRoute && _.size(validatedWaypoints) > 1;

Therefore, when you delete a waypoint which causes the new situation to not satisfy that condition (validated waypoints <= 1), it is not removed.

What changes do you think we should make in order to solve the problem?

We should clear errorFields.route when deleting a waypoint (Transaction.removeWaypoint), similar to what we already do when saving a waypoint:

// Empty out errors when we're saving a new waypoint as this indicates the user is updating their input
errorFields: {
route: null,
},

What alternative solutions did you explore? (Optional)

In DistanceRequest.js, we can add a useEffect to set errorFields.route to null if _.size(validatedWaypoints) is <= 1 and hasRouteError is true.

@hungvu193
Copy link
Contributor

hungvu193 commented Sep 15, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Wrong error is shown for maximum distance limitation even after deleting way point

What is the root cause of that problem?

I agree with Sam about the RCA.

 const shouldFetchRoute = (!doesRouteExist || haveWaypointsChanged) && !isLoadingRoute && _.size(validatedWaypoints) > 1; 

We're only receiving the error from backend, so in this case, the _.size(validatedWaypoints) > 1 is false, which make our component didn't refetch the transaction, so the error still persist.

What changes do you think we should make in order to solve the problem?

Because we only validate the waypoint through backend, we can clear the error while deleting a waypoint, after user choose another route or the shouldFetchRoute is true, our component will refresh and show the error if necessary.
So we should update removeWaypoint function optimisticData:

    // Doing a deep clone of the transaction to avoid mutating the original object and running into a cache issue when using Onyx.set
    const newTransaction = {
        ...transaction,
        comment: {
            ...transaction.comment,
            waypoints: reIndexedWaypoints,
        },
        // Clear the existing route so that we don't show an old route
        routes: {
            route0: {
                geometry: {
                    coordinates: null,
                },
            },
        },
        errorFields: {
            route: null,
        },
    };

What alternative solutions did you explore? (Optional)

N/A

@parasharrajat
Copy link
Member

Note to all proposals:

Please re-state the problem that we are trying to solve in this issue.

We expect your own understanding of the problem, not the title to be reposted. Please think about this in future proposals. This could alone become a reason for rejection even if the solution is correct.

Root cause and problem understanding are as important as solution.

@parasharrajat
Copy link
Member

@samh-nl's proposal looks good to me. It solves the problem at hand.

🎀 👀 🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

Triggered auto assignment to @Li357, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@samh-nl
Copy link
Contributor

samh-nl commented Sep 15, 2023

@parasharrajat Ok thanks for pointing out.

So there's no misunderstanding, because I see @hungvu193 has the same approach. I last updated at 5.23 PM (GMT+2), and 3 mins later at 5.26 PM (GMT+2) @hungvu193 posted.

@hungvu193
Copy link
Contributor

@parasharrajat Ok thanks for pointing out.

So there's no misunderstanding, because I see @hungvu193 has the same approach. I last updated at 5.23 PM (GMT+2), and 3 mins later at 5.26 PM (GMT+2) @hungvu193 posted.

Yeah, I posted proposal then reload the page then I saw you already updated yours. GG. I'll beat you next time 😂

@samh-nl
Copy link
Contributor

samh-nl commented Sep 15, 2023

I'm glad I pushed that Save button quickly 😎

@ahmedGaber93
Copy link
Contributor

@parasharrajat

As Expected Result: The error should disappear or change to something related ...

I think the second option "change to something related" is a better user experience, we can handle new error "start and finish points are identical"
because the user now is select the start and finish point, but button "Next" still disable without displaying any errors.

I respect your decision, But I just want to understand.

@parasharrajat
Copy link
Member

I expect the error to come from the backend same as it is being done for the maximum length reached. And I don't think we consider it wrong when the start and stop locations are the same. If that is the case we can think about that too.

@melvin-bot melvin-bot bot added the Overdue label Sep 18, 2023
@parasharrajat
Copy link
Member

Awaiting @Li357 review.

@melvin-bot melvin-bot bot removed the Overdue label Sep 18, 2023
@neil-marcellini
Copy link
Contributor

@Li357 I can take this over for you if you like. Lmk.

@Li357
Copy link
Contributor

Li357 commented Sep 19, 2023

Sorry about the delay here! This didn't show up in my K2 for some reason... @samh-nl's proposal looks good!

@mallenexpensify
Copy link
Contributor

@kevinksullivan , I removed your assignment, I was added via the Bug label and you were added later.

Sorry about the delay here! This didn't show up in my K2 for some reason... @samh-nl's proposal looks good!

@Li357 , let me know if that happens again, K2 usually works well.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 20, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 21, 2023

🎯 ⚡️ Woah @parasharrajat / @samh-nl, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @samh-nl got assigned: 2023-09-19 01:51:47 Z
  • when the PR got merged: 2023-09-21 05:02:36 UTC

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 25, 2023
@melvin-bot melvin-bot bot changed the title [$500] [Distance] - Wrong error is shown for maximum distance limitation even after deleting way point [HOLD for payment 2023-10-02] [$500] [Distance] - Wrong error is shown for maximum distance limitation even after deleting way point Sep 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.73-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-02. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 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:

  • [@parasharrajat] The PR that introduced the bug has been identified. Link to the PR:
  • [@parasharrajat] 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:
  • [@parasharrajat] 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:
  • [@parasharrajat] Determine if we should create a regression test for this bug.
  • [@parasharrajat] 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.
  • [@mallenexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Oct 1, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 4, 2023

@Li357, @mallenexpensify, @parasharrajat, @samh-nl Whoops! This issue is 2 days overdue. Let's get this updated quick!

@mallenexpensify
Copy link
Contributor

Issue reporter: @Nathan-Mulugeta paid $50 via Upwork
Contributor: @samh-nl paid $750 via Upwork
Contributor+: @parasharrajat due $750 via NewDot

@parasharrajat, please fill out the BZ checklist above

@melvin-bot melvin-bot bot removed the Overdue label Oct 4, 2023
@parasharrajat parasharrajat mentioned this issue Oct 5, 2023
57 tasks
@parasharrajat
Copy link
Member

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:

  • [@parasharrajat] The PR that introduced the bug has been identified. Link to the PR: Display Route #25434
  • [@parasharrajat] 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: https://github.com/Expensify/App/pull/25434/files#r1347604616
  • [@parasharrajat] 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: Nothing new. Can be discovered with testing.
  • [@parasharrajat] Determine if we should create a regression test for this bug. Yes
  • [@parasharrajat] 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.

Regression Test Steps

  1. Open the FAB menu.
  2. Go to Request money.
  3. Go to the Distance tab.
  4. Add 'Ethiopia' as the starting waypoint.
  5. Add 'United States' as the finishing waypoint.
  6. Press Add stop.
  7. Add 'United states' as the newly added waypoint.
  8. Verify that a 'Route exceeds maximum distance limitation' error occurs.
  9. Delete the 'Ethiopia' waypoint.
  10. Verify that the previous error 'Route exceeds maximum distance limitation' is cleared.

Do you agree 👍 or 👎 ?

@parasharrajat
Copy link
Member

Payment requested as per #27538 (comment)

@JmillsExpensify
Copy link

$750 payment approved for @parasharrajat based on BZ summary above.

@melvin-bot melvin-bot bot added the Overdue label Oct 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2023

@Li357, @mallenexpensify, @parasharrajat, @samh-nl Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@parasharrajat
Copy link
Member

This is ready to be closed.

@melvin-bot melvin-bot bot removed the Overdue label Oct 9, 2023
@mallenexpensify
Copy link
Contributor

TestRail GH created, thanks all!
https://github.com/Expensify/Expensify/issues/324411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants