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-09] [$500] [Distance] - Route is generated without green line connecting the points after going online #26589

Closed
6 tasks done
lanitochka17 opened this issue Sep 2, 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

@lanitochka17
Copy link

lanitochka17 commented Sep 2, 2023

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


Issue found when executing PR #25980

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go offline
  3. Go to + > Request money > Distance
  4. Go to Start > Select address 1 Telegraph Hill Blvd, San Francisco, CA 94133, USA
  5. Go to Finish > Select address 88 Kearny St, San Francisco, CA 94108, USA
  6. Go online

Expected Result:

The route is generated from the start to the finish point with a green line connecting

Actual Result:

The route is generated without a green line connecting the start and finish point

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.62-1

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Bug6186274_20230902_222139.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017f0ebdf18950167a
  • Upwork Job ID: 1699079489951641600
  • Last Price Increase: 2023-09-05
  • Automatic offers:
    • ntdiary | Reviewer | 26511344
    • pradeepmdk | Contributor | 26511347
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 2, 2023

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

@melvin-bot
Copy link

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

@hoangzinh
Copy link
Contributor

hoangzinh commented Sep 3, 2023

Proposal

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

Distance - Route is generated without green line connecting the points after going online

What is the root cause of that problem?

We already have a logic to fetch the route if needed

useEffect(() => {
if (isOffline || !shouldFetchRoute) {
return;
}
Transaction.getRoute(iou.transactionID, waypoints);
}, [shouldFetchRoute, iou.transactionID, waypoints, isOffline]);

But the issue is shouldFetchRoute doesn't set correctly

const doesRouteExist = lodashHas(transaction, 'routes.route0.geometry.coordinates');
const shouldFetchRoute = (!doesRouteExist || haveWaypointsChanged) && !isLoadingRoute && TransactionUtils.validateWaypoints(waypoints);

It checks doesRouteExist but we use lodashHas so it only check whether we have that key in an object, it doesn't check the value of it. In this case, even transaction.routes.route0.geometry.coordinates is null but it still returns true => It would make shouldFetchRoute is false => doesn't fetch the route when network is online back.

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

We should check the value of transaction.routes.route0.geometry.coordinates is exist or not instead of checking its key in this line => it will make shouldFetchRoute is true => will fetch the route when network is online back.

What alternative solutions did you explore? (Optional)

In the optimistic data when we saveWaypoint/addStop/removeWaypoint, we set transaction.routes.route0.geometry.coordinates to null

routes: {
route0: {
geometry: {
coordinates: null,
},
},
},

I think we can change it to set transaction.routes or transaction.routes.route0 is null. It will make the line check lodashHas key above work more properly.

@hayata-suenaga
Copy link
Contributor

hayata-suenaga commented Sep 4, 2023

Proposal
Please re-state the problem that we are trying to solve in this issue.
Display route line when the device comes back online

What is the root cause of that problem?
App/src/components/DistanceRequest.js

Line 92 in d0b2772

const doesRouteExist = lodashHas(transaction, 'routes.route0.geometry.coordinates');

here we are checking the coordinates key or not so its will be always true
because coordinates we are setting as null every every waypoint save
App/src/libs/actions/Transaction.js

Line 63 in d0b2772

coordinates: null,

but its have null value so that when come back online
App/src/components/DistanceRequest.js

Line 158 in d0b2772

Transaction.getRoute(iou.transactionID, waypoints);
not triggering this one
What changes do you think we should make in order to solve the problem?
we should update the logic

const doesRouteExist = lodashHas(transaction, 'routes.route0.geometry.coordinates') && transaction.routes.route0.geometry.coordinates && transaction. routes.route0.geometry.type;

token init as well we should update

useEffect(() => {
    if(isOffline) {
        return;
    }
    MapboxToken.init();
    return MapboxToken.stop;
}, [isOffline]);

when refresh as well working fine

This is a proposal from @pradeepmdk from this dupe issue (which I closed).

This proposal looks good. I'll assign @pradeepmdk

@pradeepmdk I don't think we have to call MapboxToken.init() when the device comes back online. I believe MapboxToken.init() already handles that situation. Could you test without the change in the useEffect for MapboxToken.init() and see if the code still works?

@hoangzinh thank you for letting me know about the dupe. You identified the cause correctly, but I don't believe we need to update the logic for optimistic update. I prefer we set the key but leave the value null (I believe this is the pattern we use across App).

@hayata-suenaga
Copy link
Contributor

Also, @pradeepmdk could you comment something on this issue? Otherwise, I cannot assign you 😓

@pradeepmdk
Copy link
Contributor

pradeepmdk commented Sep 4, 2023

from #26596 (comment)

Proposal

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

Display route line when the device comes back online

What is the root cause of that problem?

const doesRouteExist = lodashHas(transaction, 'routes.route0.geometry.coordinates');

here we are checking the coordinates key or not so its will be always true
because coordinates we are setting as null every every waypoint save
coordinates: null,

but its have null value so that when come back online
Transaction.getRoute(iou.transactionID, waypoints);
not triggering this one

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

we should update the logic

    const doesRouteExist = lodashHas(transaction, 'routes.route0.geometry.coordinates') && transaction.routes.route0.geometry.coordinates && transaction. routes.route0.geometry.type;

or
we can use null check from lodash

const doesRouteExist = !_.isNull(transaction, 'routes.route0.geometry.coordinates')

Or we can check coordinate is an array so if not an array also we use it here from Lodash
when refresh as well working fine

@hayata-suenaga hayata-suenaga self-assigned this Sep 4, 2023
@0xmiros
Copy link
Contributor

0xmiros commented Sep 4, 2023

I can take C+ role here as I was assigned on related issue but closed

@pradeepmdk
Copy link
Contributor

@hayata-suenaga Yes we don't need that MapboxToken.init() because when coming back online GetMapboxAccessToken API is triggering.

@b4s36t4
Copy link
Contributor

b4s36t4 commented Sep 4, 2023

Proposal

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

Distance - Route is generated without green line connecting the points after going online

What is the root cause of that problem?

Coordinates are null and we're not fetching route by calling getROute method even if go offline.

https://github.com/Expensify/App/blob/aeffabf2d39af8ef03440d5d69bcb074d1826dd7/src/components/DistanceRequest.js#L92 this will be true even if we have null.

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

We could simply change it to the following line.

    const doesRouteExist = lodashGet(transaction, 'routes.route0.geometry.coordinates') !== null;

This will set https://github.com/Expensify/App/blob/aeffabf2d39af8ef03440d5d69bcb074d1826dd7/src/components/DistanceRequest.js#L93 true when we come back online this will trigger route calling api.

What alternative solutions did you explore? (Optional)

NA

Result

Kapture.2023-09-04.at.10.17.37.mp4

@hoangzinh
Copy link
Contributor

@hayata-suenaga how about my main proposal. It checks value of coordinate instead of checking keys exits

@hayata-suenaga
Copy link
Contributor

@pradeepmdk I apologize for the delay in assigning you to this issue 🙇

This issue doesn't have a particularly high priority in terms of Distance Request. So we don't have to hurry into merging the PR.

@pradeepmdk
Copy link
Contributor

@hayata-suenaga np. I will raise the PR. Can you make this external? so that an upwork contract will be created.

@lanitochka17 lanitochka17 changed the title Distance - Route is generated without green line connecting the points after going online [Distance] - Route is generated without green line connecting the points after going online Sep 5, 2023
@hayata-suenaga hayata-suenaga added the External Added to denote the issue can be worked on by a contributor label Sep 5, 2023
@melvin-bot melvin-bot bot changed the title [Distance] - Route is generated without green line connecting the points after going online [$500] [Distance] - Route is generated without green line connecting the points after going online Sep 5, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 5, 2023

Job added to Upwork: https://www.upwork.com/jobs/~017f0ebdf18950167a

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

melvin-bot bot commented Sep 5, 2023

Current assignee @sakluger is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Sep 5, 2023

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

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

pradeepmdk commented Sep 8, 2023

@ntdiary @hayata-suenaga Pr is ready for review

@ntdiary
Copy link
Contributor

ntdiary commented Sep 8, 2023

That is a good and interesting point.
PR #26836 fixed the flow of:

  • open distance request --> render the map --> offline --> online,

but it didn't fix the flow of:

  • offline --> open distance request --> online --> close distance request --> re-open distance request.

I think the latter is also worth discussing and fixing. : )

cc @hayata-suenaga

demo.mp4

Clear the mapboxAccessToken and refresh page to ensure the token does not exist before the flow starts.

@hayata-suenaga
Copy link
Contributor

offline --> open distance request --> online --> close distance request --> re-open distance request.

Does this mean that closing the distance request page before the token is fetched after the device comes back online?

@ntdiary
Copy link
Contributor

ntdiary commented Sep 11, 2023

Does this mean that closing the distance request page before the token is fetched after the device comes back online?

Eh, actually the token is only fetched when the distance request page is opened for the first time. And the most critical steps in this flow are the first two: If the user fails to fetch the token when opening the distance request page for the first time due to being offline, then no matter how many times the page is opened afterwards, even if the device comes back online, the map will never be able to load (unless the page is refreshed).

demo.mp4

@ntdiary
Copy link
Contributor

ntdiary commented Sep 11, 2023

Hi, @hayata-suenaga, so, personally I think it's worth fixing, do you think we can move forward with PR #26998 ? If so, we can resolve the conflicts with PR #26836 later. 🙂

@melvin-bot
Copy link

melvin-bot bot commented Sep 26, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @pradeepmdk got assigned: 2023-09-05 17:04:07 Z
  • when the PR got merged: 2023-09-26 04:38:03 UTC
  • days elapsed: 14

On to the next one 🚀

@neil-marcellini
Copy link
Contributor

I'm marking this as done. Let's handle payment and get it closed. If we still need more PRs please update the status to LOW again. Thanks.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 2, 2023
@melvin-bot melvin-bot bot changed the title [$500] [Distance] - Route is generated without green line connecting the points after going online [HOLD for payment 2023-10-09] [$500] [Distance] - Route is generated without green line connecting the points after going online Oct 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 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 Oct 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.75-12 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-09. 🎊

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 Oct 2, 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:

  • [@ntdiary] The PR that introduced the bug has been identified. Link to the PR:
  • [@ntdiary] 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:
  • [@ntdiary] 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:
  • [@ntdiary] Determine if we should create a regression test for this bug.
  • [@ntdiary] 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.
  • [@sakluger] 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 Daily KSv2 labels Oct 9, 2023
@sakluger
Copy link
Contributor

All paid out! Thanks everyone.

@melvin-bot melvin-bot bot removed the Overdue label Oct 12, 2023
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

9 participants