@@ -262,7 +262,7 @@ import {buildOptimisticPolicyRecentlyUsedTags, getPolicyTagsData} from './Policy
262262import type {GuidedSetupData} from './Report';
263263import {buildInviteToRoomOnyxData, completeOnboarding, getCurrentUserAccountID, notifyNewAction, optimisticReportLastData} from './Report';
264264import {clearAllRelatedReportActionErrors} from './ReportActions';
265- import {getRecentWaypoints, sanitizeRecentWaypoints} from './Transaction';
265+ import {sanitizeRecentWaypoints} from './Transaction';
266266import {removeDraftSplitTransaction, removeDraftTransaction, removeDraftTransactions} from './TransactionEdit';
267267import {getOnboardingMessages} from './Welcome/OnboardingFlow';
268268
@@ -943,6 +943,15 @@ Onyx.connectWithoutView({
943943 callback: (value) => (recentAttendees = value),
944944});
945945
946+ // TODO: remove `recentWaypoints` from this file (https://github.com/Expensify/App/issues/73024)
947+ // `recentWaypoints` was moved here temporarily from `src/libs/actions/Policy/Tag.ts` during the `Deprecate Onyx.connect` refactor.
948+ // All uses of this variable should be replaced with `useOnyx`.
949+ let recentWaypoints: OnyxTypes.RecentWaypoint[] = [];
950+ Onyx.connect({
951+ key: ONYXKEYS.NVP_RECENT_WAYPOINTS,
952+ callback: (val) => (recentWaypoints = val ?? []),
953+ });
954+
946955/**
947956 * @deprecated This function uses Onyx.connect and should be replaced with useOnyx for reactive data access.
948957 * All usages of this function should be replaced with useOnyx hook in React components.
@@ -5162,7 +5171,7 @@ function updateMoneyRequestDistance({
51625171 const {params, onyxData} = data;
51635172
51645173 if (!distance) {
5165- const recentServerValidatedWaypoints = getRecentWaypoints() .filter((item) => !item.pendingAction);
5174+ const recentServerValidatedWaypoints = recentWaypoints .filter((item) => !item.pendingAction);
51665175 onyxData?.failureData?.push({
51675176 onyxMethod: Onyx.METHOD.SET,
51685177 key: `${ONYXKEYS.NVP_RECENT_WAYPOINTS}`,
@@ -6400,7 +6409,7 @@ function trackExpense(params: CreateTrackExpenseParams) {
64006409 }) ?? {};
64016410 const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport?.reportID;
64026411
6403- const recentServerValidatedWaypoints = getRecentWaypoints() .filter((item) => !item.pendingAction);
6412+ const recentServerValidatedWaypoints = recentWaypoints .filter((item) => !item.pendingAction);
64046413 onyxData?.failureData?.push({
64056414 onyxMethod: Onyx.METHOD.SET,
64066415 key: `${ONYXKEYS.NVP_RECENT_WAYPOINTS}`,
@@ -8127,7 +8136,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest
81278136 };
81288137 }
81298138
8130- const recentServerValidatedWaypoints = getRecentWaypoints() .filter((item) => !item.pendingAction);
8139+ const recentServerValidatedWaypoints = recentWaypoints .filter((item) => !item.pendingAction);
81318140 onyxData?.failureData?.push({
81328141 onyxMethod: Onyx.METHOD.SET,
81338142 key: `${ONYXKEYS.NVP_RECENT_WAYPOINTS}`,
0 commit comments