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 2024-10-17] [$250] Distance - Invalid waypoints aren't cleared when a request fails #48631

Closed
6 tasks done
izarutskaya opened this issue Sep 5, 2024 · 50 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

@izarutskaya
Copy link

izarutskaya commented Sep 5, 2024

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


Version Number: 9.0.29-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/4919784
Email or phone of affected tester (no customers): [email protected]
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Navigate to staging.new.expensify.com
  2. Create a workspace
  3. Go to workspace chat
  4. Go offline
  5. Go to submit distance expense
  6. Enter an invalid waypoint and click save
  7. Add another waypoint and continue to submit the expense
  8. Go online
  9. Verify the request fails
  10. Green plus, submit an expense, distance
  11. Go to enter a waypoint

Expected Result:

Invalid waypoints should be removed from suggestion list

Actual Result:

Invalid waypoints stay on the suggestion list

Workaround:

Submit a distance expense with valid waypoints, which will clear any invalid recent waypoints. Or. sign out and back in, since the invalid recent waypoints are only on the frontend.

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Screen.Recording.2024-10-01.at.11.48.15.AM.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021833644939720857104
  • Upwork Job ID: 1833644939720857104
  • Last Price Increase: 2024-09-10
  • Automatic offers:
    • suneox | Reviewer | 104234581
    • wildan-m | Contributor | 104234583
Issue OwnerCurrent Issue Owner: @johncschuster
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 5, 2024
Copy link

melvin-bot bot commented Sep 5, 2024

Triggered auto assignment to @johncschuster (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.

@izarutskaya
Copy link
Author

We think this issue might be related to the #collect project.

@nyomanjyotisa
Copy link
Contributor

nyomanjyotisa commented Sep 5, 2024

Edited by proposal-police: This proposal was edited at 2024-09-05 11:08:41 UTC.

Proposal

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

Distance - Invalid waypoint stays on suggestion list

What is the root cause of that problem?

We don't filter out the invalid waypoint from recentWaypoints here

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

Filter out the invalid waypoint (the waypoint with lat and long equal to 0). Add the following filter to this selector

.filter((waypoint) => waypoint.lat !== 0 && waypoint.lng !== 0)

if we need to prevent selecting invalid waypoints when the network is offline we can change this and this to the following

        if (waypointValue !== '' && waypointAddress !== waypointValue) {
            ErrorUtils.addErrorMessage(errors, `waypoint${pageIndex}`, translate('distance.error.selectSuggestedAddress'));
        }
        hint={translate('distance.error.selectSuggestedAddress')}

image

What alternative solutions did you explore? (Optional)

Or we can just don't add the invalid waypoint to the recent waypoints here

if (!recentWaypointAlreadyExists && waypoint !== null && waypoint.lat !== 0 && waypoint.lng !== 0) {

@melvin-bot melvin-bot bot added the Overdue label Sep 9, 2024
Copy link

melvin-bot bot commented Sep 10, 2024

@johncschuster Eep! 4 days overdue now. Issues have feelings too...

@johncschuster johncschuster added the External Added to denote the issue can be worked on by a contributor label Sep 10, 2024
@melvin-bot melvin-bot bot changed the title Distance - Invalid waypoint stays on suggestion list [$250] Distance - Invalid waypoint stays on suggestion list Sep 10, 2024
Copy link

melvin-bot bot commented Sep 10, 2024

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

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

melvin-bot bot commented Sep 10, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Sep 10, 2024
@suneox
Copy link
Contributor

suneox commented Sep 11, 2024

@nyomanjyotisa Thank you for your proposal, but we also need to prevent selecting invalid waypoints when the network is slow or offline.

@nkdengineer
Copy link
Contributor

Proposal

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

Invalid waypoints stay on the suggestion list

What is the root cause of that problem?

Here we only check the waypoint is empty or not to decide to save this waypoint to recent list

if (!recentWaypointAlreadyExists && waypoint !== null) {
const clonedWaypoints = lodashClone(recentWaypoints);
clonedWaypoints.unshift(waypoint);
Onyx.merge(ONYXKEYS.NVP_RECENT_WAYPOINTS, clonedWaypoints.slice(0, CONST.RECENT_WAYPOINTS_NUMBER));

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

We can use the waypointHasValidAddress function as we do here to check the waypoint is valid or not before saving it to recent list

if (!recentWaypointAlreadyExists && waypoint && TransactionUtils.waypointHasValidAddress(waypoint)) {
    const clonedWaypoints = lodashClone(recentWaypoints);
    clonedWaypoints.unshift(waypoint);
    Onyx.merge(ONYXKEYS.NVP_RECENT_WAYPOINTS, clonedWaypoints.slice(0, CONST.RECENT_WAYPOINTS_NUMBER));
}

if (!recentWaypointAlreadyExists && waypoint !== null) {
const clonedWaypoints = lodashClone(recentWaypoints);
clonedWaypoints.unshift(waypoint);
Onyx.merge(ONYXKEYS.NVP_RECENT_WAYPOINTS, clonedWaypoints.slice(0, CONST.RECENT_WAYPOINTS_NUMBER));

What alternative solutions did you explore? (Optional)

@nyomanjyotisa
Copy link
Contributor

Proposal updated

@suneox
Copy link
Contributor

suneox commented Sep 11, 2024

@johncschuster I’d like to confirm should we prevent selecting invalid waypoints in offline mode? (currently, we don’t validate waypoints in offline mode) to maintain consistency with the online flow.

RPReplay_Final1726056389-1.MP4

@trjExpensify
Copy link
Contributor

but we also need to prevent selecting invalid waypoints when the network is slow or offline.

Why so? Don't we do that validation when you come back online? 🤔 CC: @neil-marcellini for vis on this issue.

@nkdengineer
Copy link
Contributor

I think we should only prevent saving invalid waypoints to the recent list because if we prevent selecting invalid waypoint in offline, the user that doesn't have recent waypoints list can't create distance request in offline.

@suneox
Copy link
Contributor

suneox commented Sep 12, 2024

Why so? Don't we do that validation when you come back online?

@trjExpensify Currently, when submitting an expense with an invalid waypoint, the backend does not accept it. Therefore, I think we should also prevent selecting an invalid waypoint in offline mode to ensure consistency.

Screenshot 2024-09-12 at 19 12 02

RPReplay_Final1726131672_2.mp4

@trjExpensify
Copy link
Contributor

I think we should only prevent saving invalid waypoints to the recent list because if we prevent selecting invalid waypoint in offline, the user that doesn't have recent waypoints list can't create distance request in offline.

I agree. We shouldn't save invalid waypoints to recents, they're useless. But we shouldn't prevent selecting invalid waypoints, because we don't know if they are valid or not when you're offline, so then you couldn't create a distance request when offline.

@suneox
Copy link
Contributor

suneox commented Sep 13, 2024

But we shouldn't prevent selecting invalid waypoints, because we don't know if they are valid or not when you're offline, so then you couldn't create a distance request when offline.

Based on the expected result @nkdengineer proposal LGTM

Based on the expected result @nyomanjyotisa alternative proposal LGTM

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Sep 13, 2024

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

@nyomanjyotisa
Copy link
Contributor

nyomanjyotisa commented Sep 13, 2024

But we shouldn't prevent selecting invalid waypoints, because we don't know if they are valid or not when you're offline, so then you couldn't create a distance request when offline.

Based on the expected result @nkdengineer proposal LGTM

🎀 👀 🎀 C+ reviewed

I believe my alternative solution is works as the expected results

and the selected solution won't works since waypointHasValidAddress only checks for waypoint?.address and invalid waypoint has address data

function waypointHasValidAddress(waypoint: RecentWaypoint | Waypoint): boolean {
return !!waypoint?.address?.trim();
}

image

@suneox
Copy link
Contributor

suneox commented Sep 13, 2024

I’d like to clarify that the selected solution is to prevent saving an invalid waypoint, rather than filtering out the invalid waypoints in the list. The implementation details can be addressed during the code review process. The alternative solution proposed by @nyomanjyotisa is the same as @nkdengineer solution, which is to prevent saving an invalid waypoint. However, I selected @nkdengineer proposal because it was posted before @nyomanjyotisa notify an update.

But I just double-checked, and it turns out that the updated proposal (at 2024-09-11T03:14:11Z) was actually submitted before the new proposal (at 2024-09-11T03:14:32Z).

Sorry everyone, this was my mistake for not checking the detailed update times, so I’ve updated the selected proposal accordingly.

@wildan-m
Copy link
Contributor

wildan-m commented Oct 1, 2024

Proposal Updated

Instead of identify recentValidatedWaypoints using pending action, we can filter it using lat, lng and name

item => item.lat !== 0 && item.lng !== 0 && !isEmpty(item.name)

@suneox
Copy link
Contributor

suneox commented Oct 2, 2024

@neil-marcellini Based on the latest expected behavior, we can proceed with the updated alternative proposal from @wildan-m.

@neil-marcellini
Copy link
Contributor

Ok sweet, I'm glad we've landed on a solution! I like @wildan-m's proposal too. I keep changing my mind, but I like the main solution with the pendingAction approach. Either way could work but that's slightly more clear, and I forgot in my last comment that we need a way to identify the current waypoints that have been saved by the server vs offline. Hiring 🚀

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

📣 @suneox 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Oct 2, 2024

📣 @wildan-m 🎉 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 📖

@wildan-m
Copy link
Contributor

wildan-m commented Oct 3, 2024

@neil-marcellini Thanks for the assignment, please confirm that we'll go with adding pendingAction? If so, we'll need backend modification as mentioned here #48631 (comment) and explained more here #48631 (comment)

Copy link

melvin-bot bot commented Oct 3, 2024

@johncschuster @wildan-m @suneox @neil-marcellini this issue is now 4 weeks old, please consider:

  • Finding a contributor to fix the bug
  • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
  • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

Thanks!

@wildan-m
Copy link
Contributor

wildan-m commented Oct 4, 2024

@neil-marcellini bump #48631 (comment)

@wildan-m
Copy link
Contributor

wildan-m commented Oct 7, 2024

@suneox The PR is ready #50323. 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 10, 2024
@melvin-bot melvin-bot bot changed the title [$250] Distance - Invalid waypoints aren't cleared when a request fails [HOLD for payment 2024-10-17] [$250] Distance - Invalid waypoints aren't cleared when a request fails Oct 10, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 10, 2024
Copy link

melvin-bot bot commented Oct 10, 2024

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

Copy link

melvin-bot bot commented Oct 10, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.47-4 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 2024-10-17. 🎊

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

Copy link

melvin-bot bot commented Oct 10, 2024

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:

  • [@suneox] The PR that introduced the bug has been identified. Link to the PR:
  • [@suneox] 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:
  • [@suneox] 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:
  • [@suneox] Determine if we should create a regression test for this bug.
  • [@suneox] 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.
  • [@johncschuster] 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 and removed Weekly KSv2 labels Oct 17, 2024
@suneox
Copy link
Contributor

suneox commented Oct 18, 2024

Checklist

  • [@suneox] The PR that introduced the bug has been identified. Link to the PR: N/A
  • [@suneox] 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. There isn’t an offending PR in this case, as this is a new requirement intended to cover an edge case.​
  • [@suneox] 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: N/A
  • [@suneox] Determine if we should create a regression test for this bug: N/A
  • [@suneox] 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. N/A

@melvin-bot melvin-bot bot added the Overdue label Oct 21, 2024
@johncschuster
Copy link
Contributor

Payment Summary:

Contributor: @wildan-m paid $250 via Upwork
Contributor+: @suneox paid $250 via Upwork

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
No open projects
Status: Polish
Development

No branches or pull requests

8 participants