Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.49k stars 2.84k forks source link

[HOLD for payment 2023-09-29] [$500] BUG: [distance] request map is cut off after going online #26540

Closed neil-marcellini closed 1 year ago

neil-marcellini commented 1 year ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Run App on latest main branch (for now)
  2. Sign in with an account on the distance requests beta (or enable all betas)
  3. Go offline
  4. Click green plus, request money, distance, enter start and finish addresses
  5. Click next
  6. Go online and maybe wait a bit
  7. Go back to the page with the map

Expected Result:

The route renders properly on the map and it's not cut off

Actual Result:

The bottom section of the map is cut off and the bottom corners are not rounded

Workaround:

Ignore it

Platforms:

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

Version Number: unreleased Reproducible in staging?: Not yet Reproducible in production?: Not yet 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: Originally reported by @situchan in a PR review here Expensify/Expensify Issue URL: Issue reported by: @situchan Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693609781739659

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016004dbcd8eeeb10d
  • Upwork Job ID: 1697749501998895104
  • Last Price Increase: 2023-09-08
  • Automatic offers:
    • nahid633 | Contributor | 26681342
    • situchan | Reporter | 26681346
melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

Job added to Upwork: https://www.upwork.com/jobs/~016004dbcd8eeeb10d

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

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

neil-marcellini commented 1 year ago

Side note:bug: if I create a new issue with external and bug labels it assigns two BZ.

b4s36t4 commented 1 year ago

@neil-marcellini when we go back to online, the amount should be update there itself? means ConfirmPage itself or the user needs to go back the page?

b4s36t4 commented 1 year ago

Proposal

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

[distance] request map is cut off after going online

What is the root cause of that problem?

Considerably there are two problems here.

  1. To show TBD.

Even though we don't have access to how much distance the ride is we're still calculating the distance amount here https://github.com/Expensify/App/blob/7217a18a78ec2b01a45267f476fd95ed0cde0fb0/src/libs/DistanceRequestUtils.js#L72 in this function which is returning odd amount.

We can return "TBD" if the distanceInMiles is 0.

The usage of this function is getting refactored in other PR which could give us a way to do this in MoneyRequestConfirmationList component itself. Above point is only for reference. Also we need to consider the network status before just giving TBD

We can do same with Amount menu as well. Just some conditionals within MoneyRequestConfirmationList component.

  1. Getting Values when going back to online.

On MoneyRequestConfirmationList we're rendering the map and when we go offline in money request page we'll call GetRoutes command which will return us the route and distance etc which we use to calculate distance and then amount based on it.

But while creating if we're offline we won't be having it so the route will be null even if go online which require us to close the modal and go up again.

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

To fix this we need to do two changes.

Here in this useEffect https://github.com/Expensify/App/blob/7217a18a78ec2b01a45267f476fd95ed0cde0fb0/src/components/DistanceRequest.js#L154

we need update the logic as below


if ((isOffline && _.isEmpty(waypoints)) || !shouldFetchRoute) {
    return;
}

Which will refetch the request if there are waypoints and we've updated our online status.

But this only requires us to come back to the first page again, which won't be the case everytime.

To update the routes inside ConfirmedRoute we also need to call the GetRoute command there as well.


    useEffect(() => {
        // If the network is offline or we have the coordinate we don't need to call the api again.
        if (isOffline || !_.isEmpty(coordinates)) return;
        Transaction.getRoute(transaction.transactionID, waypoints);
    }, [coordinates, isOffline, transaction.transactionID, waypoints]);

What alternative solutions did you explore? (Optional)

NA

@neil-marcellini Please review the proposal. Sorry for the ping if you're not going to review :)

paultsimura commented 1 year ago

@neil-marcellini please note that my proposal in https://github.com/Expensify/App/issues/26537 fixes the route rendering issue. These 2 bugs look quite related. Also it seems like @b4s36t4 's proposal belongs more to that issue than to this one.

studentofcoding commented 1 year ago

Proposal

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

BUG: [distance] request map is cut off after going online

What is the root cause of that problem?

The bug appears because the application does not re-fetch the MapBox route when transitioning from offline to online. This means that if the user goes offline and then comes back online, the MapBox route is not updated, causing it not to appear correctly.

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

Add a mechanism to https://github.com/Expensify/App/blob/d0b277206ff8b80f8b447ecb49437cec0446f2f8/src/components/DistanceRequest.js#L76 using useEffect to listens for changes in the network status and triggers a re-fetch of the MapBox route when the application goes from offline to online.

function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken}) {
    const previousIsOffline = usePrevious(isOffline); // Add this line to store the previous network status

    // ... (rest of the code)

    // Add this useEffect hook
    useEffect(() => {
        if (!previousIsOffline || isOffline || !iou.transactionID) {
            return;
        }

        Transaction.getRoute(iou.transactionID, waypoints);
    }, [isOffline, previousIsOffline, iou.transactionID, waypoints]);

    // ... (rest of the code)
}

What alternative solutions did you explore? (Optional)

None

Result

https://github.com/Expensify/App/assets/20473526/39f14bec-f300-4ed1-8cff-103f1189938f

studentofcoding commented 1 year ago

Proposal

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

BUG: [distance] request map is cut off after going online

What is the root cause of that problem?

The bug appears because the application does not re-fetch the MapBox route when transitioning from offline to online. This means that if the user goes offline and then comes back online, the MapBox route is not updated, causing it not to appear correctly.

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

Add a mechanism to

https://github.com/Expensify/App/blob/d0b277206ff8b80f8b447ecb49437cec0446f2f8/src/components/DistanceRequest.js#L76

using useEffect to listens for changes in the network status and triggers a re-fetch of the MapBox route when the application goes from offline to online.

function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken}) {
    const previousIsOffline = usePrevious(isOffline); // Add this line to store the previous network status

    // ... (rest of the code)

    // Add this useEffect hook
    useEffect(() => {
        if (!previousIsOffline || isOffline || !iou.transactionID) {
            return;
        }

        Transaction.getRoute(iou.transactionID, waypoints);
    }, [isOffline, previousIsOffline, iou.transactionID, waypoints]);

    // ... (rest of the code)
}

What alternative solutions did you explore? (Optional)

None

Result

cropped_mapbox_fixed.mp4

cc : @neil-marcellini

b4s36t4 commented 1 year ago

@studentofcoding I don't think you understand the bug correctly. This isn't about loading the route or not.

Sometimes when you only have two waypoints and move offline and online back and forth and doing some things like closing modal selecting an address or adding and removing multiple waypoints causing the map to cutoff.

Like in your video you have the map fully, but the bug is you'll be having the map but the bottom of the map like 10-15% of it is showing as black which is weird and that is the bug.

Let me know if you don't understand the bug.

ArekChr commented 1 year ago

@neil-marcellini, could you please provide a video showing the actual results of this issue and specify which platforms are affected?

trjExpensify commented 1 year ago

@ArekChr a video came with the report here by @situchan in the PR: https://github.com/Expensify/App/pull/25707#pullrequestreview-1606168005

nahid633 commented 1 year ago

Proposal

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

BUG: [distance] request map is cut off after going online

What is the root cause of that problem?

The problem is related to Mapbox resizing.It is related to the size of the container where the is located.

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

we should call mapRef.resize(). For that we need ResizeObserver to detect size changes on the canvas container.

What alternative solutions did you explore? (Optional)

none

https://github.com/Expensify/App/assets/22540272/f292a211-e093-445b-9d5d-f63320611619

melvin-bot[bot] commented 1 year ago

πŸ“£ @nahid633! πŸ“£ Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
nahid633 commented 1 year ago

Contributor details Your Expensify account email: quliyevn633@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~018b5a73519689f99a

melvin-bot[bot] commented 1 year ago

βœ… Contributor details stored successfully. Thank you for contributing to Expensify!

ArekChr commented 1 year ago

we should call mapRef.resize(). For that we need ResizeObserver to detect size changes on the canvas container.

This fix looks good πŸ‘Œ @nahid633 Could you provide more details on which place should be this function called?

nahid633 commented 1 year ago

@ArekChr In MapView component inside useEffect(() => we need to add

          const resizeObserver = new ResizeObserver(() => {
               mapRef.resize();
            });
            resizeObserver.observe(mapRef.getContainer());
nahid633 commented 1 year ago

@ArekChr tagging you for reviewing.

melvin-bot[bot] commented 1 year ago

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

melvin-bot[bot] commented 1 year ago

@trjExpensify, @ArekChr, @neil-marcellini Eep! 4 days overdue now. Issues have feelings too...

melvin-bot[bot] commented 1 year ago

@trjExpensify, @ArekChr, @neil-marcellini Eep! 4 days overdue now. Issues have feelings too...

trjExpensify commented 1 year ago

@ArekChr can you review this please? Thanks!

ArekChr commented 1 year ago

@nahid633 It seems MapView doesn't have methods such as resize or getContainer

nahid633 commented 1 year ago

@ArekChr https://github.com/Expensify/App/blob/main/src/components/MapView/MapView.web.tsx line 40.

            const resizeObserver = new ResizeObserver(() => {
                mapRef?.resize();
            });

            resizeObserver.observe(mapRef.getContainer());
ArekChr commented 1 year ago

Thanks @nahid633, Looked in the wrong file. This actually solves the problem, the proposal LGTM

:ribbon: :eyes: :ribbon: C+ reviewed

melvin-bot[bot] commented 1 year ago

Current assignee @neil-marcellini is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

trjExpensify commented 1 year ago

Woop! @neil-marcellini can you give this the green light, so we can get @nahid633 going on the PR. Thanks!

neil-marcellini commented 1 year ago

Ah yeah sorry I missed this for a bit.

the proposal LGTM

I agree with C+.

melvin-bot[bot] commented 1 year ago

πŸ“£ @nahid633 πŸŽ‰ 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[bot] commented 1 year ago

πŸ“£ @situchan πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reporter role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] commented 1 year ago

@trjExpensify @nahid633 @ArekChr @neil-marcellini 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!

ArekChr commented 1 year ago

@nahid633 Friendly bump, any progress with the PR?

nahid633 commented 1 year ago

Hey @ArekChr , i got offer from upwork today. I will finish and create PR today.

nahid633 commented 1 year ago

@ArekChr PR is ready

melvin-bot[bot] commented 1 year ago

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

On to the next one πŸš€

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

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

If no regressions arise, payment will be issued on 2023-09-29. :confetti_ball:

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.

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:

melvin-bot[bot] commented 1 year ago

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:

trjExpensify commented 1 year ago

πŸ‘‹ @ArekChr can you get tot he checklist please so we can proceed with the payments? Thanks!

melvin-bot[bot] commented 1 year ago

@trjExpensify, @nahid633, @ArekChr, @neil-marcellini Whoops! This issue is 2 days overdue. Let's get this updated quick!

trjExpensify commented 1 year ago

Awaiting the above!

ArekChr commented 1 year ago
trjExpensify commented 1 year ago

Thanks! I tend to agree a visual display issue like a cut off map will be captured in the regression testing of the distance feature, so we don't need a standalone one.

Confirming payments as follows:

Settled up, closing!