diff --git a/src/components/DistanceRequest/index.js b/src/components/DistanceRequest/index.js index 3a41d52eb7f4..eb6811d02323 100644 --- a/src/components/DistanceRequest/index.js +++ b/src/components/DistanceRequest/index.js @@ -150,13 +150,8 @@ function DistanceRequest({transactionID, report, transaction, route, isEditingRe return ErrorUtils.getLatestErrorField(transaction, 'route'); } - // 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. - if (_.keys(waypoints).length === 2 && lodashGet(waypoints, 'waypoint0.address', 'address1') === lodashGet(waypoints, 'waypoint1.address', 'address2')) { - return {0: translate('iou.error.duplicateWaypointsErrorMessage')}; - } - if (_.size(validatedWaypoints) < 2) { - return {0: translate('iou.error.emptyWaypointsErrorMessage')}; + return {0: translate('iou.error.atLeastTwoDifferentWaypoints')}; } }; diff --git a/src/languages/en.ts b/src/languages/en.ts index c186a1fffedf..01a0488d7ff1 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -592,8 +592,7 @@ export default { genericDeleteFailureMessage: 'Unexpected error deleting the money request, please try again later', genericEditFailureMessage: 'Unexpected error editing the money request, please try again later', genericSmartscanFailureMessage: 'Transaction is missing fields', - duplicateWaypointsErrorMessage: 'Please remove duplicate waypoints', - emptyWaypointsErrorMessage: 'Please enter at least two waypoints', + atLeastTwoDifferentWaypoints: 'Please enter at least two different addresses', splitBillMultipleParticipantsErrorMessage: 'Split bill is only allowed between a single workspace or individual users. Please update your selection.', }, waitingOnEnabledWallet: ({submitterDisplayName}: WaitingOnBankAccountParams) => `Started settling up, payment is held until ${submitterDisplayName} enables their Wallet`, diff --git a/src/languages/es.ts b/src/languages/es.ts index a0a30bcf4141..592ccf5f2c30 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -586,8 +586,7 @@ export default { genericDeleteFailureMessage: 'Error inesperado eliminando la solicitud de dinero. Por favor, inténtalo más tarde', genericEditFailureMessage: 'Error inesperado al guardar la solicitud de dinero. Por favor, inténtalo más tarde', genericSmartscanFailureMessage: 'La transacción tiene campos vacíos', - duplicateWaypointsErrorMessage: 'Por favor elimina los puntos de ruta duplicados', - emptyWaypointsErrorMessage: 'Por favor introduce al menos dos puntos de ruta', + atLeastTwoDifferentWaypoints: 'Por favor introduce al menos dos direcciones diferentes', splitBillMultipleParticipantsErrorMessage: 'Solo puedes dividir una cuenta entre un único espacio de trabajo o con usuarios individuales. Por favor actualiza tu selección.', }, waitingOnEnabledWallet: ({submitterDisplayName}: WaitingOnBankAccountParams) => `Inició el pago, pero no se procesará hasta que ${submitterDisplayName} active su Billetera`, diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index 2cc63e63e753..00ce8c55dbd7 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -417,6 +417,7 @@ function getValidWaypoints(waypoints: WaypointCollection, reArrangeIndexes = fal } let lastWaypointIndex = -1; + let waypointIndex = -1; return waypointValues.reduce((acc, currentWaypoint, index) => { const previousWaypoint = waypointValues[lastWaypointIndex]; @@ -431,9 +432,10 @@ function getValidWaypoints(waypoints: WaypointCollection, reArrangeIndexes = fal return acc; } - const validatedWaypoints: WaypointCollection = {...acc, [`waypoint${reArrangeIndexes ? lastWaypointIndex + 1 : index}`]: currentWaypoint}; + const validatedWaypoints: WaypointCollection = {...acc, [`waypoint${reArrangeIndexes ? waypointIndex + 1 : index}`]: currentWaypoint}; - lastWaypointIndex += 1; + lastWaypointIndex = index; + waypointIndex += 1; return validatedWaypoints; }, {});