Skip to content

Commit 3e44b3d

Browse files
authored
Merge pull request Expensify#75116 from bernhardoj/fix/74529-can-save-same-waypoint-using-user-current-location
Fix user can save duplicate user current location as distance waypoints
2 parents cef3164 + 7a23e52 commit 3e44b3d

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';
@@ -1359,8 +1361,10 @@ function getValidWaypoints(waypoints: WaypointCollection | undefined, reArrangeI
13591361
return acc;
13601362
}
13611363

1362-
// Check for adjacent waypoints with the same address
1363-
if (previousWaypoint && currentWaypoint?.address === previousWaypoint.address) {
1364+
// Check for adjacent waypoints with the same address or coordinate
1365+
const previousCoordinate: Coordinate = [previousWaypoint?.lng ?? 0, previousWaypoint?.lat ?? 0];
1366+
const currentCoordinate: Coordinate = [currentWaypoint.lng ?? 0, currentWaypoint.lat ?? 0];
1367+
if (previousWaypoint && (currentWaypoint?.address === previousWaypoint.address || utils.areSameCoordinate(previousCoordinate, currentCoordinate))) {
13641368
return acc;
13651369
}
13661370

0 commit comments

Comments
 (0)