You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$500] Distance - Inconsistency in error message when more than two same adddress is added #29803
changed the title [-] Distance - Inconsistency in error message when more than two same adddress is added[/-][+][$500] Distance - Inconsistency in error message when more than two same adddress is added[/+]on Oct 17, 2023
Please re-state the problem that we are trying to solve in this issue.
Inconsistent error message while adding duplicate waypoints.
What is the root cause of that problem?
The root cause for this problem is the logic used in the onError function that returns the error message, which checks duplication only the waypoints have no additional points init _.keys(waypoints).length === 2 .
which leads to hit to the final if conditions and returns the Please enter at least two waypoints.
// Initially, both waypoints will be null, and if we give fallback value as empty string that will result in true condition, that's why different default values.
also, I noticed the error handling is not done properly and it only checks if it has any two valid points. That introduces bugs like allowing duplicate waypoints if they have any two valid points.
What changes do you think we should make in order to solve the problem?
to fix the error handling properly we can introduce the memo variable hasInValidWayPoints which tracks differences in original waypoints and validatedWaypoints which has the list of unique and valid waypoints.
const getError = () => {
// Get route error if available else show the invalid number of waypoints error.
if (hasRouteError) {
return ErrorUtils.getLatestErrorField(transaction, 'route');
}
const startAddress = lodashGet(waypoints, 'waypoint0.address', {})
const finalAddress = lodashGet(waypoints, 'waypoint1.address', {})
// check start and final waypoints is empty
if (_.keys(waypoints).length === 2 && (_.isEmpty(startAddress) || _.isEmpty(finalAddress))) {
return { 0: translate('iou.error.emptyWaypointsErrorMessage') };
}
// Checking Duplicates in waypoints from start to end
if (hasInValidWayPoints) {
return {0: translate('iou.error.duplicateWaypointsErrorMessage')};
}
};
Then update the logic on submitWaypoints to prevent submission and set hasError to true.
const submitWaypoints = useCallback(() => {
// If there is any error or loading state, don't let user go to next page.
if ( hasInValidWayPoints || hasRouteError || isLoadingRoute || isLoading) {
setHasError(true);
return;
}
onSubmit(waypoints);
}, [onSubmit, setHasError, hasRouteError, isLoadingRoute, isLoading, waypoints, hasInValidWayPoints]);
Then update the logic on showing error in view.
{/* Show error message if there is route error or there are less than 2 routes and use
r has tried submitting, */}
{((hasError && hasInValidWayPoints) || hasRouteError) && (
<DotIndicatorMessage
style={[styles.mh4, styles.mv3]}
messages={getError()}
type="error"
/>
)}
📣 @kuttyhub! 📣
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:
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.
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.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
ah sorry i missed your comment last week @tgolen -- i don't know anything about the payments, i'm just on this GH for the copy. should there be someone from the contributor team who handles that?
Activity
[-] Distance - Inconsistency in error message when more than two same adddress is added[/-][+][$500] Distance - Inconsistency in error message when more than two same adddress is added[/+]melvin-bot commentedon Oct 17, 2023
Triggered auto assignment to @puneetlath (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Oct 17, 2023
Job added to Upwork: https://www.upwork.com/jobs/~018cedadf58c08d896
melvin-bot commentedon Oct 17, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Oct 17, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ntdiary (
External)tgolen commentedon Oct 17, 2023
@BhuvaneshPatil this is related to the changes in #29125. Can you work on correcting this, please?
BhuvaneshPatil commentedon Oct 17, 2023
Sure thing @tgolen.
What should be the error message here?
kuttyhub commentedon Oct 18, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Inconsistent error message while adding duplicate waypoints.
What is the root cause of that problem?
The root cause for this problem is the logic used in the onError function that returns the error message, which checks duplication only the waypoints have no additional points init
_.keys(waypoints).length === 2.which leads to hit to the final if conditions and returns the
Please enter at least two waypoints.App/src/components/DistanceRequest/index.js
Lines 148 to 162 in b494186
also, I noticed the error handling is not done properly and it only checks if it has any two valid points. That introduces bugs like allowing duplicate waypoints if they have any two valid points.
App/src/components/DistanceRequest/index.js
Lines 226 to 233 in b494186
App/src/components/DistanceRequest/index.js
Lines 185 to 192 in b494186
check the recordings for the bug.
https://github.com/Expensify/App/assets/71143839/37328a72-1da2-452f-937e-76dc2794db9d
What changes do you think we should make in order to solve the problem?
to fix the error handling properly we can introduce the memo variable
hasInValidWayPointswhich tracks differences in original waypoints and validatedWaypoints which has the list of unique and valid waypoints.Then update the OnError functions logic:
Then update the logic on submitWaypoints to prevent submission and set hasError to true.
Then update the logic on showing error in view.
by using the
hasInValidWayPointsvalue now we can properly updatehasErrorstate and it prevents submitting. demo here,https://github.com/Expensify/App/assets/71143839/c5afa8d2-d60e-41cb-a029-9f4725056e06
What alternative solutions did you explore? (Optional)
N/A
melvin-bot commentedon Oct 18, 2023
📣 @kuttyhub! 📣
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:
Format:
60 remaining items
tgolen commentedon Dec 4, 2023
bump @GabiHExpensify
GabiHExpensify commentedon Dec 4, 2023
ah sorry i missed your comment last week @tgolen -- i don't know anything about the payments, i'm just on this GH for the copy. should there be someone from the contributor team who handles that?
tgolen commentedon Dec 4, 2023
Oops, sorry about that! I'll get someone from the bugzero team.
melvin-bot commentedon Dec 4, 2023
Triggered auto assignment to @sonialiap (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Dec 4, 2023
tgolen commentedon Dec 4, 2023
@sonialiap Could you help us settle up some payments here? I think this is what is needed:
tgolen commentedon Dec 5, 2023
bump @sonialiap
tgolen commentedon Dec 6, 2023
bump @sonialiap
sonialiap commentedon Dec 6, 2023
@dukenv0307 contributor $500 - offer sent - paid ✔️
@ntdiary reviewer $500 - offer sent - paid ✔️
ntdiary commentedon Dec 6, 2023
@sonialiap, thank you! Have accepted. :)
sonialiap commentedon Dec 8, 2023
Everyone has been paid ✔️
Seems like we're good to close