Skip to content

Commit 7a23e52

Browse files
committed
fix user can save duplicate user current location as distance waypoints
1 parent 5da2ba3 commit 7a23e52

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libs/TransactionUtils/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import lodashSet from 'lodash/set';
66
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
77
import Onyx from 'react-native-onyx';
88
import type {ValueOf} from 'type-fest';
9+
import type {Coordinate} from '@components/MapView/MapViewTypes';
10+
import utils from '@components/MapView/utils';
911
import type {UnreportedExpenseListItemType} from '@components/SelectionListWithSections/types';
1012
import {getPolicyTagsData} from '@libs/actions/Policy/Tag';
1113
import type {MergeDuplicatesParams} from '@libs/API/parameters';
@@ -1308,8 +1310,10 @@ function getValidWaypoints(waypoints: WaypointCollection | undefined, reArrangeI
13081310
return acc;
13091311
}
13101312

1311-
// Check for adjacent waypoints with the same address
1312-
if (previousWaypoint && currentWaypoint?.address === previousWaypoint.address) {
1313+
// Check for adjacent waypoints with the same address or coordinate
1314+
const previousCoordinate: Coordinate = [previousWaypoint?.lng ?? 0, previousWaypoint?.lat ?? 0];
1315+
const currentCoordinate: Coordinate = [currentWaypoint.lng ?? 0, currentWaypoint.lat ?? 0];
1316+
if (previousWaypoint && (currentWaypoint?.address === previousWaypoint.address || utils.areSameCoordinate(previousCoordinate, currentCoordinate))) {
13131317
return acc;
13141318
}
13151319

0 commit comments

Comments
 (0)