Skip to content

Commit 39bcb75

Browse files
neil-marcelliniOSBotify
authored andcommitted
Merge pull request #92110 from Expensify/revert-88538-transition-tracker-batch-2
[No QA] Revert "[BATCH 2] Migrate Navigation usage, part 1" (cherry picked from commit e1bf6ce) (cherry-picked to staging by Julesssss)
1 parent 91ef021 commit 39bcb75

20 files changed

Lines changed: 130 additions & 183 deletions

config/eslint/eslint.seatbelt.tsv

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"../../src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 3
124124
"../../src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx" "react-hooks/refs" 6
125125
"../../src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx" "react-hooks/set-state-in-effect" 3
126+
"../../src/components/MoneyRequestReportView/MoneyRequestReportView.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
126127
"../../src/components/MultiGestureCanvas/index.tsx" "no-restricted-syntax" 1
127128
"../../src/components/MultiGestureCanvas/index.tsx" "react-hooks/preserve-manual-memoization" 1
128129
"../../src/components/MultiGestureCanvas/index.tsx" "react-hooks/refs" 2
@@ -208,7 +209,7 @@
208209
"../../src/hooks/useDialogContainerFocus/index.ts" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
209210
"../../src/hooks/useDomainGroupFilter.ts" "react-hooks/set-state-in-effect" 1
210211
"../../src/hooks/useDragAndDrop/types.ts" "@typescript-eslint/no-deprecated/React.MutableRefObject" 1
211-
"../../src/hooks/useExpenseActions.ts" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 2
212+
"../../src/hooks/useExpenseActions.ts" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 3
212213
"../../src/hooks/useFilesValidation.tsx" "@typescript-eslint/no-deprecated/ConfirmModal" 1
213214
"../../src/hooks/useInitial.ts" "react-hooks/refs" 4
214215
"../../src/hooks/useIsBlockedToAddFeed.ts" "react-hooks/set-state-in-effect" 1
@@ -386,19 +387,20 @@
386387
"../../src/libs/actions/ReimbursementAccount/resetNonUSDBankAccount.ts" "no-restricted-syntax" 1
387388
"../../src/libs/actions/ReimbursementAccount/resetUSDBankAccount.ts" "no-restricted-syntax" 1
388389
"../../src/libs/actions/Report/MarkAllMessageAsRead.tsx" "no-restricted-syntax" 1
389-
"../../src/libs/actions/Report/index.ts" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
390+
"../../src/libs/actions/Report/index.ts" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 2
390391
"../../src/libs/actions/Report/index.ts" "@typescript-eslint/no-deprecated/buildNextStepNew" 3
391392
"../../src/libs/actions/Report/index.ts" "@typescript-eslint/no-deprecated/reportAction.originalMessage" 1
392393
"../../src/libs/actions/Report/index.ts" "no-restricted-syntax" 10
393394
"../../src/libs/actions/Report/index.ts" "rulesdir/no-onyx-connect" 4
394395
"../../src/libs/actions/ReportLayout.ts" "no-restricted-syntax" 1
395396
"../../src/libs/actions/ScheduleCall.ts" "no-restricted-syntax" 1
396397
"../../src/libs/actions/Search.ts" "no-restricted-syntax" 1
397-
"../../src/libs/actions/Session/index.ts" "no-restricted-imports" 1
398+
"../../src/libs/actions/Session/index.ts" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
398399
"../../src/libs/actions/Session/index.ts" "no-restricted-syntax" 9
399400
"../../src/libs/actions/Session/index.ts" "rulesdir/no-onyx-connect" 2
400401
"../../src/libs/actions/StatsCounter.ts" "no-restricted-syntax" 2
401402
"../../src/libs/actions/Subscription.ts" "no-restricted-syntax" 1
403+
"../../src/libs/actions/Task.ts" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
402404
"../../src/libs/actions/Task.ts" "no-restricted-syntax" 7
403405
"../../src/libs/actions/TaxRate.ts" "no-restricted-syntax" 1
404406
"../../src/libs/actions/TeachersUnite.ts" "no-restricted-syntax" 1
@@ -464,7 +466,7 @@
464466
"../../src/pages/RoomMembersPage.tsx" "react-hooks/set-state-in-effect" 1
465467
"../../src/pages/ScheduleCall/ScheduleCallPage.tsx" "react-hooks/preserve-manual-memoization" 1
466468
"../../src/pages/Search/SearchAdvancedFiltersPage/SearchFiltersCardPage.tsx" "react-hooks/set-state-in-effect" 1
467-
"../../src/pages/Search/SearchMoneyRequestReportPage.tsx" "no-restricted-imports" 1
469+
"../../src/pages/Search/SearchMoneyRequestReportPage.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
468470
"../../src/pages/Search/SearchPage.tsx" "react-hooks/set-state-in-effect" 1
469471
"../../src/pages/Search/SearchTransactionsChangeReport.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
470472
"../../src/pages/Share/ShareRootPage.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
@@ -473,12 +475,13 @@
473475
"../../src/pages/ValidateLoginPage/index.web.tsx" "react-hooks/set-state-in-effect" 1
474476
"../../src/pages/domain/Groups/PreferredWorkspaceToggle.tsx" "@typescript-eslint/no-deprecated/ConfirmModal" 1
475477
"../../src/pages/domain/Saml/SamlLoginSectionContent.tsx" "@typescript-eslint/no-deprecated/ConfirmModal" 1
476-
"../../src/pages/inbox/DeleteTransactionNavigateBackHandler.tsx" "no-restricted-imports" 1
478+
"../../src/pages/inbox/DeleteTransactionNavigateBackHandler.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
477479
"../../src/pages/inbox/ReportFetchHandler.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 2
478480
"../../src/pages/inbox/ReportNavigateAwayHandler.tsx" "react-hooks/exhaustive-deps" 1
479481
"../../src/pages/inbox/hooks/useDeferNonEssentials.ts" "no-restricted-imports" 2
480482
"../../src/pages/inbox/hooks/useFlushDeferredWriteOnFocus.ts" "no-restricted-imports" 1
481483
"../../src/pages/inbox/hooks/useReportWasDeleted.ts" "react-hooks/set-state-in-effect" 1
484+
"../../src/pages/inbox/report/ContextMenu/BaseReportActionContextMenu.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
482485
"../../src/pages/inbox/report/ContextMenu/BaseReportActionContextMenu.tsx" "react-hooks/preserve-manual-memoization" 1
483486
"../../src/pages/inbox/report/ContextMenu/BaseReportActionContextMenu.tsx" "react-hooks/refs" 1
484487
"../../src/pages/inbox/report/ContextMenu/PopoverReportActionContextMenu.tsx" "@typescript-eslint/no-deprecated/ConfirmModal" 1
@@ -495,7 +498,7 @@
495498
"../../src/pages/inbox/report/ReportActionItemMessageEdit.tsx" "react-hooks/preserve-manual-memoization" 1
496499
"../../src/pages/inbox/report/ReportActionItemMessageEdit.tsx" "react-hooks/refs" 5
497500
"../../src/pages/inbox/report/ReportActionItemMessageEdit.tsx" "react-hooks/set-state-in-effect" 1
498-
"../../src/pages/inbox/report/ReportActionsList.tsx" "no-restricted-imports" 1
501+
"../../src/pages/inbox/report/ReportActionsList.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 4
499502
"../../src/pages/inbox/report/ReportActionsList.tsx" "react-hooks/refs" 5
500503
"../../src/pages/inbox/report/ReportActionsList.tsx" "react-hooks/set-state-in-effect" 3
501504
"../../src/pages/inbox/report/TripSummary.tsx" "rulesdir/no-default-id-values" 1
@@ -624,6 +627,7 @@
624627
"../../src/pages/workspace/companyCards/WorkspaceVerifyWorkAccountPage.tsx" "react-hooks/set-state-in-effect" 1
625628
"../../src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx" "@typescript-eslint/no-deprecated/ConfirmModal" 1
626629
"../../src/pages/workspace/companyCards/addNew/PlaidConnectionStep.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
630+
"../../src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 1
627631
"../../src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx" "react-hooks/preserve-manual-memoization" 1
628632
"../../src/pages/workspace/downgrade/WorkspaceDowngradePage.tsx" "@typescript-eslint/no-deprecated/ConfirmModal" 1
629633
"../../src/pages/workspace/downgrade/WorkspaceDowngradePage.tsx" "@typescript-eslint/no-deprecated/InteractionManager.runAfterInteractions" 2

src/components/MoneyRequestHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type MoneyRequestHeaderProps = {
4848
reportID: string | undefined;
4949

5050
/** Method to trigger when pressing close button of the header */
51-
onBackButtonPress: (prioritizeBackTo?: boolean, options?: {afterTransition?: () => void}) => void;
51+
onBackButtonPress: (prioritizeBackTo?: boolean) => void;
5252
};
5353

5454
function MoneyRequestHeader({reportID: reportIDProp, onBackButtonPress}: MoneyRequestHeaderProps) {

src/components/MoneyRequestHeaderActions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type MoneyRequestHeaderActionsProps = {
1616
reportID: string | undefined;
1717

1818
/** Method to trigger when pressing close button of the header */
19-
onBackButtonPress: (prioritizeBackTo?: boolean, options?: {afterTransition?: () => void}) => void;
19+
onBackButtonPress: (prioritizeBackTo?: boolean) => void;
2020
};
2121

2222
function MoneyRequestHeaderActions({reportID, onBackButtonPress}: MoneyRequestHeaderActionsProps) {

src/components/MoneyRequestHeaderSecondaryActions.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {shouldFailAllRequestsSelector} from '@selectors/Network';
33
import {hasSeenTourSelector} from '@selectors/Onboarding';
44
import {validTransactionDraftsSelector} from '@selectors/TransactionDraft';
55
import React, {useRef, useState} from 'react';
6+
// eslint-disable-next-line no-restricted-imports
7+
import {InteractionManager} from 'react-native';
68
import type {ValueOf} from 'type-fest';
79
import useConfirmModal from '@hooks/useConfirmModal';
810
import {useCurrencyListActions} from '@hooks/useCurrencyList';
@@ -82,7 +84,7 @@ type MoneyRequestHeaderSecondaryActionsProps = {
8284
reportID: string | undefined;
8385

8486
/** Method to trigger when pressing close button of the header */
85-
onBackButtonPress: (prioritizeBackTo?: boolean, options?: {afterTransition?: () => void}) => void;
87+
onBackButtonPress: (prioritizeBackTo?: boolean) => void;
8688
};
8789

8890
function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: MoneyRequestHeaderSecondaryActionsProps) {
@@ -443,8 +445,6 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
443445
}
444446
const backToRoute = route.params?.backTo ?? Navigation.getActiveRoute();
445447
setDeleteTransactionNavigateBackUrl(backToRoute);
446-
447-
let afterDelete: (() => void) | undefined;
448448
if (isTrackExpenseAction(parentReportAction) && !isExpenseSplit) {
449449
deleteTrackExpense({
450450
chatReportID: report?.parentReportID,
@@ -467,7 +467,8 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
467467
deleteTransactions([transaction.transactionID], duplicateTransactions, duplicateTransactionViolations, currentSearchHash, true);
468468
return;
469469
}
470-
afterDelete = () => {
470+
// eslint-disable-next-line @typescript-eslint/no-deprecated
471+
InteractionManager.runAfterInteractions(() => {
471472
const deleteResult = deleteTransactions(
472473
[transaction.transactionID],
473474
duplicateTransactions,
@@ -481,14 +482,14 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
481482
}
482483

483484
removeTransaction(transaction.transactionID);
484-
};
485+
});
485486
}
486487
if (isInNarrowPaneModal) {
487-
Navigation.navigateBackToLastSuperWideRHPScreen({afterTransition: afterDelete});
488+
Navigation.navigateBackToLastSuperWideRHPScreen();
488489
return;
489490
}
490491

491-
onBackButtonPress(false, {afterTransition: afterDelete});
492+
onBackButtonPress();
492493
});
493494
},
494495
},

src/components/MoneyRequestReportView/MoneyRequestReportView.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, {useCallback, useEffect, useMemo} from 'react';
33
// We use Animated for all functionality related to wide RHP to make it easier
44
// to interact with react-navigation components (e.g., CardContainer, interpolator), which also use Animated.
55
// eslint-disable-next-line no-restricted-imports
6-
import {Animated, ScrollView, View} from 'react-native';
6+
import {Animated, InteractionManager, ScrollView, View} from 'react-native';
77
import type {LayoutChangeEvent} from 'react-native';
88
import type {OnyxEntry} from 'react-native-onyx';
99
import CollapsibleHeaderOnKeyboard from '@components/CollapsibleHeaderOnKeyboard';
@@ -61,7 +61,7 @@ type MoneyRequestReportViewProps = {
6161
onLayout?: (event: LayoutChangeEvent) => void;
6262
};
6363

64-
function goBackFromSearchMoneyRequest(options?: {afterTransition?: () => void}) {
64+
function goBackFromSearchMoneyRequest() {
6565
const rootState = navigationRef.getRootState();
6666
const lastRoute = rootState.routes.at(-1);
6767

@@ -71,7 +71,7 @@ function goBackFromSearchMoneyRequest(options?: {afterTransition?: () => void})
7171
}
7272

7373
if (lastRoute?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
74-
Navigation.goBack(undefined, options);
74+
Navigation.goBack();
7575
return;
7676
}
7777

@@ -81,11 +81,11 @@ function goBackFromSearchMoneyRequest(options?: {afterTransition?: () => void})
8181
}
8282

8383
if (rootState.routes.length > 1) {
84-
Navigation.goBack(undefined, options);
84+
Navigation.goBack();
8585
return;
8686
}
8787

88-
Navigation.goBack(ROUTES.SEARCH_ROOT.getRoute({query: buildCannedSearchQuery()}), options);
88+
Navigation.goBack(ROUTES.SEARCH_ROOT.getRoute({query: buildCannedSearchQuery()}));
8989
}
9090

9191
function InitialLoadingSkeleton({styles, onLayout, reasonAttributes}: {styles: ThemeStyles; onLayout?: (event: LayoutChangeEvent) => void; reasonAttributes: SkeletonSpanReasonAttributes}) {
@@ -144,7 +144,8 @@ function MoneyRequestReportView({report, reportLoadingState, shouldDisplayReport
144144

145145
const isLoadingInitialReportActions = reportLoadingState?.isLoadingInitialReportActions;
146146
const dismissReportCreationError = useCallback(() => {
147-
goBackFromSearchMoneyRequest({afterTransition: () => removeFailedReport(reportID)});
147+
goBackFromSearchMoneyRequest();
148+
InteractionManager.runAfterInteractions(() => removeFailedReport(reportID));
148149
}, [reportID]);
149150

150151
// Special case handling a report that is a transaction thread

src/components/SidePanel/SidePanelContextProvider.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type SidePanelStateContextProps = {
3333

3434
type SidePanelActionsContextProps = {
3535
openSidePanel: () => void;
36-
closeSidePanel: (options?: {afterTransition?: () => void}) => void;
36+
closeSidePanel: () => void;
3737
};
3838

3939
const SidePanelStateContext = createContext<SidePanelStateContextProps>({
@@ -88,7 +88,6 @@ function SidePanelContextProvider({children}: PropsWithChildren) {
8888

8989
const reportID = (isRHPAdminsRoom || isRHPHomePage) && isUserAdmin && isPolicyActive && adminsChatReportID ? adminsChatReportID : conciergeReportID;
9090

91-
const onCloseCompleteRef = useRef<(() => void) | undefined>(undefined);
9291
const [sessionStartTime, setSessionStartTime] = useState<string | null>(null);
9392
const [prevShouldHideSidePanel, setPrevShouldHideSidePanel] = useState(shouldHideSidePanel);
9493

@@ -122,22 +121,17 @@ function SidePanelContextProvider({children}: PropsWithChildren) {
122121
duration: CONST.SIDE_PANEL_ANIMATED_TRANSITION,
123122
useNativeDriver: true,
124123
}),
125-
]).start(() => {
126-
setIsSidePanelTransitionEnded(true);
127-
onCloseCompleteRef.current?.();
128-
onCloseCompleteRef.current = undefined;
129-
});
124+
]).start(() => setIsSidePanelTransitionEnded(true));
130125
}, [shouldHideSidePanel, shouldApplySidePanelOffset]);
131126

132-
const closeSidePanel = (options?: {afterTransition?: () => void}) => {
127+
const closeSidePanel = (shouldUpdateNarrow = false) => {
133128
// User shouldn't be able to close side panel if side panel NVP is undefined
134129
if (!sidePanelNVP) {
135130
return;
136131
}
137132

138-
onCloseCompleteRef.current = options?.afterTransition;
139133
setIsSidePanelTransitionEnded(false);
140-
SidePanelActions.closeSidePanel(!isExtraLargeScreenWidth);
134+
SidePanelActions.closeSidePanel(!isExtraLargeScreenWidth || shouldUpdateNarrow);
141135

142136
// Focus the composer after closing the Side Panel
143137
focusComposerWithDelay(ReportActionComposeFocusManager.composerRef.current, CONST.SIDE_PANEL_ANIMATED_TRANSITION + CONST.COMPOSER_FOCUS_DELAY)(true);

src/components/SidePanel/SidePanelModal/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type SidePanelModalProps = {
77
shouldHideSidePanel: boolean;
88
sidePanelTranslateX: RefObject<Animated.Value>;
99
shouldHideSidePanelBackdrop: boolean;
10-
closeSidePanel: (options?: {afterTransition?: () => void}) => void;
10+
closeSidePanel: (shouldUpdateNarrow?: boolean) => void;
1111
};
1212

1313
export default SidePanelModalProps;

src/hooks/useExpenseActions.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -555,19 +555,18 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
555555
setDeleteTransactionNavigateBackUrl(deleteNavigateBackUrl);
556556

557557
Navigation.setNavigationActionToMicrotaskQueue(() => {
558-
Navigation.goBack(backToRoute, {
559-
afterTransition: () => {
560-
deleteAppReport({
561-
report: moneyRequestReport,
562-
selfDMReport,
563-
currentUserEmailParam: email ?? '',
564-
currentUserAccountIDParam: accountID,
565-
reportTransactions,
566-
allTransactionViolations,
567-
bankAccountList,
568-
hash: currentSearchHash,
569-
});
570-
},
558+
Navigation.goBack(backToRoute);
559+
InteractionManager.runAfterInteractions(() => {
560+
deleteAppReport({
561+
report: moneyRequestReport,
562+
selfDMReport,
563+
currentUserEmailParam: email ?? '',
564+
currentUserAccountIDParam: accountID,
565+
reportTransactions,
566+
allTransactionViolations,
567+
bankAccountList,
568+
hash: currentSearchHash,
569+
});
571570
});
572571
});
573572
},

src/libs/Navigation/Navigation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,15 +825,15 @@ function dismissModal({ref = navigationRef, afterTransition, waitForTransition}:
825825
const dismissModalWithReport = (
826826
{reportID, reportActionID, referrer, backTo}: ReportsSplitNavigatorParamList[typeof SCREENS.REPORT],
827827
ref = navigationRef,
828-
options?: {onBeforeNavigate?: (willOpenReport: boolean) => void; afterTransition?: () => void},
828+
options?: {onBeforeNavigate?: (willOpenReport: boolean) => void},
829829
) => {
830830
const dismissAndOpenReport = () => {
831831
const topmostSuperWideRHPReportID = getTopmostSuperWideRHPReportID();
832832
let areReportsIDsDefined = !!topmostSuperWideRHPReportID && !!reportID;
833833

834834
if (topmostSuperWideRHPReportID === reportID && areReportsIDsDefined) {
835835
options?.onBeforeNavigate?.(false);
836-
dismissToSuperWideRHP({afterTransition: options?.afterTransition});
836+
dismissToSuperWideRHP();
837837
return;
838838
}
839839

@@ -842,14 +842,14 @@ const dismissModalWithReport = (
842842
const isReportsSplitTopmostFullScreen = isReportTopmostSplitNavigator();
843843
if (topmostReportID === reportID && areReportsIDsDefined && isReportsSplitTopmostFullScreen) {
844844
options?.onBeforeNavigate?.(false);
845-
dismissModal({afterTransition: options?.afterTransition});
845+
dismissModal();
846846
return;
847847
}
848848
options?.onBeforeNavigate?.(true);
849849
const reportRoute = ROUTES.REPORT_WITH_ID.getRoute(reportID, reportActionID, referrer, backTo);
850850
dismissModal({
851851
afterTransition: () => {
852-
navigate(reportRoute, {afterTransition: options?.afterTransition});
852+
navigate(reportRoute);
853853
},
854854
});
855855
};

0 commit comments

Comments
 (0)