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-01-17] [$500] Distance - Able to request money by distance by adding a stop same as finish point without enterring start point From #29895

Closed
6 tasks done
kbecciv opened this issue Oct 18, 2023 · 101 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 Engineering External Added to denote the issue can be worked on by a contributor Needs Reproduction Reproducible steps needed

Comments

@kbecciv
Copy link

kbecciv commented Oct 18, 2023

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: 1.3.86.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:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @rakshitjain13
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1697639775327799

Action Performed:

Action Performed:

  1. Open app
  2. Click on '+' FAB icon in LHS
  3. Click on Request Money
  4. Select Distance tab
  5. Click on Add stop and fill India
  6. Click on Stop and fill India
  7. Click on Next button to proceed further
  8. Able to Create Request

Expected Result:

It should not create request with not valid waypoints

Actual Result:

Able to create distance request with duplicate waypoints

Workaround:

Unknown

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

Android: Native
Screen.Recording.2023-10-16.at.7.29.43.PM.mov
Android: mWeb Chrome
Screen.Recording.2023-10-17.at.1.24.34.AM.mov
iOS: Native
Screen.Recording.2023-10-16.at.7.21.36.PM.mov
iOS: mWeb Safari
Screen.Recording.2023-10-16.at.7.21.36.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2023-10-16.at.7.36.52.PM.mov
Screen.Recording.2023-10-16.at.7.41.28.PM.mov
MacOS: Desktop
Screen.Recording.2023-10-16.at.7.33.40.PM.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f177f4854fa6146e
  • Upwork Job ID: 1714703219702423552
  • Last Price Increase: 2023-11-01
  • Automatic offers:
    • rojiphil | Contributor | 28035387
@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 Oct 18, 2023
@melvin-bot melvin-bot bot changed the title Distance - Able to request money by distance by adding a stop same as finish point without enterring start point From [$500] Distance - Able to request money by distance by adding a stop same as finish point without enterring start point From Oct 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

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

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

melvin-bot bot commented Oct 18, 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

@rakshitjain13
Copy link
Contributor

rakshitjain13 commented Oct 18, 2023

Proposal

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

Next Button Activated with Same Stop and Finish Point in Request Money

What is the root cause of that problem?

In src/components/DistanceRequest.js
we check for validwaypoint and then decide wether we have to go on next step or not . The logic is to check the size of validatedWaypoints array which is shown below .

const submitWaypoints = useCallback(() => {
// If there is any error or loading state, don't let user go to next page.
if (_.size(validatedWaypoints) < 2 || hasRouteError || isLoadingRoute || isLoading) {
setHasError(true);
return;
}
onSubmit(waypoints);
}, [onSubmit, setHasError, hasRouteError, isLoadingRoute, isLoading, validatedWaypoints, waypoints]);

Now to generate validatedWaypoints the code is in fileSrc/libs/TransactionUtils.js
function getValidWaypoints(waypoints: WaypointCollection, reArrangeIndexes = false): WaypointCollection {
const sortedIndexes = Object.keys(waypoints).map(getWaypointIndex).sort();
const waypointValues = sortedIndexes.map((index) => waypoints[`waypoint${index}`]);
// Ensure the number of waypoints is between 2 and 25
if (waypointValues.length < 2 || waypointValues.length > 25) {
return {};
}
let lastWaypointIndex = -1;
return waypointValues.reduce<WaypointCollection>((acc, currentWaypoint, index) => {
const previousWaypoint = waypointValues[lastWaypointIndex];
// Check if the waypoint has a valid address
if (!waypointHasValidAddress(currentWaypoint)) {
return acc;
}
// Check for adjacent waypoints with the same address
if (previousWaypoint && currentWaypoint?.address === previousWaypoint.address) {
return acc;
}
const validatedWaypoints: WaypointCollection = {...acc, [`waypoint${reArrangeIndexes ? lastWaypointIndex + 1 : index}`]: currentWaypoint};
lastWaypointIndex += 1;
return validatedWaypoints;
}, {});
}

This function fails in a edge case where starting waypoints are invalid because here lastWaypointIndex is equal to -1 in starting which suggests that first waypoint will always be valid when waypoints size > 1 .

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

We have to have increment lastWaypointIndex till we find some valid waypoint and then it is good to go . Here is my solution


function getValidWaypoints(waypoints: WaypointCollection, reArrangeIndexes = false): WaypointCollection { 
     const sortedIndexes = Object.keys(waypoints).map(getWaypointIndex).sort(); 
     const waypointValues = sortedIndexes.map((index) => waypoints[`waypoint${index}`]); 
     // Ensure the number of waypoints is between 2 and 25 
     if (waypointValues.length < 2 || waypointValues.length > 25) { 
         return {}; 
     } 
  
     let lastWaypointIndex = -1; 
     let foundFirstValidWaypoint = false;
  
     return waypointValues.reduce<WaypointCollection>((acc, currentWaypoint, index) => { 
         const previousWaypoint = waypointValues[lastWaypointIndex]; 

           // Skip all starting invalid waypoints
            if (foundFirstValidWaypoint == false && !waypointHasValidAddress(currentWaypoint)) {
                lastWaypointIndex += 1;
                return acc;
            } else {
                foundFirstValidWaypoint = true;
            }

  
         // Check if the waypoint has a valid address 
         if (!waypointHasValidAddress(currentWaypoint)) { 
             return acc; 
         } 
  
         // Check for adjacent waypoints with the same address 
         if (previousWaypoint && currentWaypoint?.address === previousWaypoint.address) { 
             return acc; 
         } 
  
         const validatedWaypoints: WaypointCollection = {...acc, [`waypoint${reArrangeIndexes ? lastWaypointIndex + 1 : index}`]: currentWaypoint}; 
  
         lastWaypointIndex += 1; 
  
         return validatedWaypoints; 
     }, {}); 
 } 

Here I have introduced a new variable named as foundFirstValidWaypoint which is false in starting and once we find a validwaypoint we will set it to true till the time we will increment lastWaypointIndex in each iteration .

What alternative solutions did you explore? (Optional)

We can add a check that the start point should always be there.
To do the above we have to add a new condition in the below check

if (_.size(validatedWaypoints) < 2 || hasRouteError || isLoadingRoute || isLoading) {

if (_.size(validatedWaypoints) < 2 || _.isEmpty(validatedWaypoints['wayppoint0']) || hasRouteError || isLoadingRoute || isLoading) 

leading to above adding the same condition below

if (_.size(validatedWaypoints) < 2) {
return {0: translate('iou.error.emptyWaypointsErrorMessage')};
}

 if (_.size(validatedWaypoints) < 2 || _.isEmpty(validatedWaypoints['wayppoint0']))

Also here the same condition

{((hasError && _.size(validatedWaypoints) < 2) || hasRouteError) && (
<DotIndicatorMessage
style={[styles.mh4, styles.mv3]}

((hasError && (_.size(validatedWaypoints) < 2 || _.isEmpty(validatedWaypoints['waypoint0']))) || hasRouteError)

@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

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

@kbecciv
Copy link
Author

kbecciv commented Oct 18, 2023

Linked PR #27045

@strepanier03
Copy link
Contributor

I'm not able to recreate this following the steps in the report.

I see an error:

image

Checking the link PR shared above, this GH is a regression.

Anyone able to recreate this still?

@strepanier03 strepanier03 added the Needs Reproduction Reproducible steps needed label Oct 18, 2023
@strepanier03
Copy link
Contributor

Doubled checked and both staging and prod show the error.

@rakshitjain13
Copy link
Contributor

@strepanier03 I think you misread the steps. You can follow one of the videos for information.

@0xmiroslav
Copy link
Contributor

I think this one should be closed in favor of #28477

@DylanDylann

This comment was marked as outdated.

@rakshitjain13
Copy link
Contributor

@DylanDylann I don't think so as in the above case validatedWaypoints size will be 2

@DylanDylann

This comment was marked as off-topic.

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

melvin-bot bot commented Oct 24, 2023

@strepanier03, @rushatgabhane Huh... This is 4 days overdue. Who can take care of this?

@strepanier03
Copy link
Contributor

After retesting I see where I messed up the steps and was able to create the expense.

@melvin-bot melvin-bot bot removed the Overdue label Oct 24, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 25, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@strepanier03
Copy link
Contributor

@rushatgabhane friendly bump on the proposal here when you get a chance.

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Jan 8, 2024
Copy link

melvin-bot bot commented Jan 8, 2024

This issue has not been updated in over 15 days. @rojiphil, @danieldoglas, @strepanier03, @rushatgabhane eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@danieldoglas
Copy link
Contributor

This was merged today, should be deployed to staging soon.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Monthly KSv2 labels Jan 10, 2024
@melvin-bot melvin-bot bot changed the title [$500] Distance - Able to request money by distance by adding a stop same as finish point without enterring start point From [HOLD for payment 2024-01-17] [$500] Distance - Able to request money by distance by adding a stop same as finish point without enterring start point From Jan 10, 2024
Copy link

melvin-bot bot commented Jan 10, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 10, 2024
Copy link

melvin-bot bot commented Jan 10, 2024

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

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

Copy link

melvin-bot bot commented Jan 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:

  • [@rushatgabhane] The PR that introduced the bug has been identified. Link to the PR:
  • [@rushatgabhane] 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:
  • [@rushatgabhane] 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:
  • [@rushatgabhane] Determine if we should create a regression test for this bug.
  • [@rushatgabhane] 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.
  • [@strepanier03] 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 Jan 16, 2024
@rushatgabhane
Copy link
Member

rushatgabhane commented Jan 17, 2024

  1. The PR that introduced the bug has been identified. Link to the PR: Refactor the money request creation flow #28618

  2. 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/28618/files#r1454558927

  3. 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.

  4. Determine if we should create a regression test for this bug. Sure!

  5. 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

     1. Click Request Money via Global FAB(+)
     2. Select Start Address (A)
     3. Select Finish Address (B)
     4. Click Add stop and add Address (B)
     5. Verify that you see a duplicate waypoint error message.
    

@rushatgabhane
Copy link
Member

@strepanier03 could you please add payment summary. Thank you! 🙇

@strepanier03
Copy link
Contributor

Yup, will do, today is the release day so that is the plan.

@strepanier03
Copy link
Contributor

strepanier03 commented Jan 17, 2024

Payment summary

@rakshitjain13
Copy link
Contributor

@strepanier03 Accepted the offer

@strepanier03
Copy link
Contributor

@rakshitjain13 - After reviewing this more carefully, I'm not sure why the payment comment had your name listed. I don't see that you worked on the PR or the review for this bug.

I am going to need to cancel the contract and we won't be able to pay it.

If you can link me to the work you did for this bug, I can reconsider but at this point, I don't think there's any work related to this that you need to be paid for. Is that correct?

@0xmiroslav
Copy link
Contributor

@rakshitjain13 is a bug reporter 😄

@strepanier03
Copy link
Contributor

Got it thank you @0xmiroslav , looks like it got in right before we paused the program so I'll get it sorted.

@strepanier03
Copy link
Contributor

@rakshitjain13 sorry about the confusion there, that's my bad. I have sent over a new offer for the right price as the original one I sent was for $500 and it should be $50.

@rakshitjain13
Copy link
Contributor

rakshitjain13 commented Jan 18, 2024

@strepanier03 No worry! Thank You . I thought Expensify is giving New Year gifts 🤫

@strepanier03
Copy link
Contributor

All that's left is the manual request payment for @rushatgabhane

Payment summary is here. Closing and assigning Jason.

@JmillsExpensify
Copy link

$500 payment approved for @rushatgabhane based on this summary.

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 Engineering External Added to denote the issue can be worked on by a contributor Needs Reproduction Reproducible steps needed
Projects
None yet
Development

No branches or pull requests