Skip to content

Commit 2ce24f4

Browse files
authored
Merge pull request #57934 from Expensify/puneetlath-cherry-pick-staging-56698-1
🍒 Cherry pick PR #56698 to staging 🍒
2 parents 250fb55 + a8a08a5 commit 2ce24f4

File tree

20 files changed

+145
-130
lines changed

20 files changed

+145
-130
lines changed

android/app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ android {
114114
minSdkVersion rootProject.ext.minSdkVersion
115115
targetSdkVersion rootProject.ext.targetSdkVersion
116116
multiDexEnabled rootProject.ext.multiDexEnabled
117-
versionCode 1009010906
118-
versionName "9.1.9-6"
117+
versionCode 1009010907
118+
versionName "9.1.9-7"
119119
// Supported language variants must be declared here to avoid from being removed during the compilation.
120120
// This also helps us to not include unnecessary language variants in the APK.
121121
resConfigs "en", "es"

ios/NewExpensify/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</dict>
4545
</array>
4646
<key>CFBundleVersion</key>
47-
<string>9.1.9.6</string>
47+
<string>9.1.9.7</string>
4848
<key>FullStory</key>
4949
<dict>
5050
<key>OrgId</key>

ios/NewExpensifyTests/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>9.1.9.6</string>
22+
<string>9.1.9.7</string>
2323
</dict>
2424
</plist>

ios/NotificationServiceExtension/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<key>CFBundleShortVersionString</key>
1414
<string>9.1.9</string>
1515
<key>CFBundleVersion</key>
16-
<string>9.1.9.6</string>
16+
<string>9.1.9.7</string>
1717
<key>NSExtension</key>
1818
<dict>
1919
<key>NSExtensionPointIdentifier</key>

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "new.expensify",
3-
"version": "9.1.9-6",
3+
"version": "9.1.9-7",
44
"author": "Expensify, Inc.",
55
"homepage": "https://new.expensify.com",
66
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",

src/App.tsx

+17-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ import type {Route} from './ROUTES';
4242
import './setup/backgroundTask';
4343
import {SplashScreenStateContextProvider} from './SplashScreenStateContext';
4444

45-
/** Values passed to our top-level React Native component by HybridApp. Will always be undefined in "pure" NewDot builds. */
45+
/**
46+
* Properties passed to the top-level React Native component by HybridApp.
47+
* These will always be `undefined` in "pure" NewDot builds.
48+
*/
4649
type AppProps = {
47-
/** URL containing all necessary data to run React Native app (e.g. login data) */
50+
/** The URL specifying the initial navigation destination when the app opens */
4851
url?: Route;
52+
/** Serialized configuration data required to initialize the React Native app (e.g. authentication details) */
53+
hybridAppSettings?: string;
54+
/** A timestamp indicating when the initial properties were last updated, used to detect changes */
55+
timestamp?: string;
4956
};
5057

5158
LogBox.ignoreLogs([
@@ -61,14 +68,18 @@ const fill = {flex: 1};
6168

6269
const StrictModeWrapper = CONFIG.USE_REACT_STRICT_MODE_IN_DEV ? React.StrictMode : ({children}: {children: React.ReactElement}) => children;
6370

64-
function App({url}: AppProps) {
71+
function App({url, hybridAppSettings, timestamp}: AppProps) {
6572
useDefaultDragAndDrop();
6673
OnyxUpdateManager();
6774

6875
return (
6976
<StrictModeWrapper>
7077
<SplashScreenStateContextProvider>
71-
<InitialURLContextProvider url={url}>
78+
<InitialURLContextProvider
79+
url={url}
80+
hybridAppSettings={hybridAppSettings}
81+
timestamp={timestamp}
82+
>
7283
<GestureHandlerRootView style={fill}>
7384
<ComposeProviders
7485
components={[
@@ -118,3 +129,5 @@ function App({url}: AppProps) {
118129
App.displayName = 'App';
119130

120131
export default App;
132+
133+
export type {AppProps};

src/CONST.ts

-5
Original file line numberDiff line numberDiff line change
@@ -6696,11 +6696,6 @@ const CONST = {
66966696
},
66976697
},
66986698

6699-
HYBRID_APP: {
6700-
REORDERING_REACT_NATIVE_ACTIVITY_TO_FRONT: 'reorderingReactNativeActivityToFront',
6701-
SINGLE_NEW_DOT_ENTRY: 'singleNewDotEntry',
6702-
},
6703-
67046699
MIGRATED_USER_WELCOME_MODAL: 'migratedUserWelcomeModal',
67056700

67066701
BASE_LIST_ITEM_TEST_ID: 'base-list-item-',

src/components/BookTravelButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function BookTravelButton({text}: BookTravelButtonProps) {
7575

7676
// Close NewDot if it was opened only for Travel, as its purpose is now fulfilled.
7777
Log.info('[HybridApp] Returning to OldDot after opening TravelDot');
78-
NativeModules.HybridAppModule.closeReactNativeApp(false, false);
78+
NativeModules.HybridAppModule.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: false});
7979
setRootStatusBarEnabled(false);
8080
})
8181
?.catch(() => {

src/components/InitialURLContextProvider.tsx

+11-29
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import React, {createContext, useEffect, useMemo, useState} from 'react';
22
import type {ReactNode} from 'react';
33
import {Linking} from 'react-native';
4-
import {useOnyx} from 'react-native-onyx';
5-
import type {ValueOf} from 'type-fest';
64
import {signInAfterTransitionFromOldDot} from '@libs/actions/Session';
7-
import Navigation from '@navigation/Navigation';
5+
import type {AppProps} from '@src/App';
86
import CONST from '@src/CONST';
9-
import ONYXKEYS from '@src/ONYXKEYS';
107
import type {Route} from '@src/ROUTES';
118
import {useSplashScreenStateContext} from '@src/SplashScreenStateContext';
129

@@ -21,46 +18,31 @@ const InitialURLContext = createContext<InitialUrlContextType>({
2118
setInitialURL: () => {},
2219
});
2320

24-
type InitialURLContextProviderProps = {
25-
/** URL passed to our top-level React Native component by HybridApp. Will always be undefined in "pure" NewDot builds. */
26-
url?: Route | ValueOf<typeof CONST.HYBRID_APP>;
27-
21+
type InitialURLContextProviderProps = AppProps & {
2822
/** Children passed to the context provider */
2923
children: ReactNode;
3024
};
3125

32-
function InitialURLContextProvider({children, url}: InitialURLContextProviderProps) {
26+
function InitialURLContextProvider({children, url, hybridAppSettings, timestamp}: InitialURLContextProviderProps) {
3327
const [initialURL, setInitialURL] = useState<Route | undefined>();
34-
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH);
3528
const {splashScreenState, setSplashScreenState} = useSplashScreenStateContext();
3629

3730
useEffect(() => {
38-
if (url !== CONST.HYBRID_APP.REORDERING_REACT_NATIVE_ACTIVITY_TO_FRONT) {
39-
return;
40-
}
41-
42-
if (splashScreenState !== CONST.BOOT_SPLASH_STATE.HIDDEN) {
43-
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
44-
Navigation.navigate(lastVisitedPath as Route);
45-
}
46-
}, [lastVisitedPath, setSplashScreenState, splashScreenState, url]);
47-
48-
useEffect(() => {
49-
if (url === CONST.HYBRID_APP.REORDERING_REACT_NATIVE_ACTIVITY_TO_FRONT) {
50-
return;
51-
}
52-
53-
if (url) {
54-
signInAfterTransitionFromOldDot(url).then((route) => {
55-
setInitialURL(route);
31+
if (url && hybridAppSettings) {
32+
signInAfterTransitionFromOldDot(hybridAppSettings).then(() => {
33+
setInitialURL(url);
34+
if (splashScreenState === CONST.BOOT_SPLASH_STATE.HIDDEN) {
35+
return;
36+
}
5637
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
5738
});
5839
return;
5940
}
6041
Linking.getInitialURL().then((initURL) => {
6142
setInitialURL(initURL as Route);
6243
});
63-
}, [setSplashScreenState, url]);
44+
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
45+
}, [url, hybridAppSettings, timestamp]);
6446

6547
const initialUrlContext = useMemo(
6648
() => ({

src/components/ScreenWrapper.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import {UNSTABLE_usePreventRemove, useIsFocused, useNavigation, useRoute} from '@react-navigation/native';
1+
import {UNSTABLE_usePreventRemove, useIsFocused, useNavigation} from '@react-navigation/native';
22
import type {ForwardedRef, ReactNode} from 'react';
33
import React, {createContext, forwardRef, useContext, useEffect, useMemo, useRef, useState} from 'react';
44
import type {StyleProp, ViewStyle} from 'react-native';
55
import {Keyboard, NativeModules, PanResponder, View} from 'react-native';
6+
import {useOnyx} from 'react-native-onyx';
67
import {PickerAvoidingView} from 'react-native-picker-select';
78
import type {EdgeInsets} from 'react-native-safe-area-context';
89
import useEnvironment from '@hooks/useEnvironment';
@@ -18,6 +19,7 @@ import type {ReportsSplitNavigatorParamList, RootNavigatorParamList} from '@libs
1819
import addViewportResizeListener from '@libs/VisualViewport';
1920
import toggleTestToolsModal from '@userActions/TestTool';
2021
import CONST from '@src/CONST';
22+
import ONYXKEYS from '@src/ONYXKEYS';
2123
import CustomDevMenu from './CustomDevMenu';
2224
import CustomStatusBarAndBackgroundContext from './CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext';
2325
import FocusTrapForScreens from './FocusTrap/FocusTrapForScreen';
@@ -158,6 +160,7 @@ function ScreenWrapper(
158160
// since Modals are drawn in separate native view hierarchy we should always add paddings
159161
const ignoreInsetsConsumption = !useContext(ModalContext).default;
160162
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);
163+
const [isSingleNewDotEntry] = useOnyx(ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY);
161164

162165
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout for a case where we want to show the offline indicator only on small screens
163166
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
@@ -169,14 +172,10 @@ function ScreenWrapper(
169172
const maxHeight = shouldEnableMaxHeight ? windowHeight : undefined;
170173
const minHeight = shouldEnableMinHeight && !isSafari() ? initialHeight : undefined;
171174

172-
const route = useRoute();
173-
const shouldReturnToOldDot = useMemo(() => {
174-
return !!route?.params && CONST.HYBRID_APP.SINGLE_NEW_DOT_ENTRY in route.params && route.params[CONST.HYBRID_APP.SINGLE_NEW_DOT_ENTRY] === 'true';
175-
}, [route?.params]);
176175
const {isBlurred, setIsBlurred} = useInputBlurContext();
177176

178-
UNSTABLE_usePreventRemove(shouldReturnToOldDot, () => {
179-
NativeModules.HybridAppModule?.closeReactNativeApp(false, false);
177+
UNSTABLE_usePreventRemove(isSingleNewDotEntry ?? false, () => {
178+
NativeModules.HybridAppModule?.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: false});
180179
setRootStatusBarEnabled(false);
181180
});
182181

src/libs/Notification/PushNotification/subscribePushNotification/index.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ Onyx.connect({
2626
},
2727
});
2828

29+
let isSingleNewDotEntry: boolean | undefined;
30+
Onyx.connect({
31+
key: ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY,
32+
callback: (value) => {
33+
if (!value) {
34+
return;
35+
}
36+
isSingleNewDotEntry = value;
37+
},
38+
});
39+
2940
function getLastUpdateIDAppliedToClient(): Promise<number> {
3041
return new Promise((resolve) => {
3142
Onyx.connect({
@@ -106,7 +117,7 @@ function navigateToReport({reportID, reportActionID}: ReportActionPushNotificati
106117
try {
107118
// When transitioning to the new experience via the singleNewDotEntry flow, the navigation
108119
// is handled elsewhere. So we cancel here to prevent double navigation.
109-
if (Navigation.getActiveRoute().includes(CONST.HYBRID_APP.SINGLE_NEW_DOT_ENTRY)) {
120+
if (isSingleNewDotEntry) {
110121
Log.info('[PushNotification] Not navigating because this is a singleNewDotEntry flow', false, {reportID, reportActionID});
111122
return;
112123
}

src/libs/actions/Delegate.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ function connect(email: string) {
157157

158158
NetworkStore.setAuthToken(response?.restrictedToken ?? null);
159159
confirmReadyToOpenApp();
160-
openApp().then(() => NativeModules.HybridAppModule?.switchAccount(email, restrictedToken, policyID, String(previousAccountID)));
160+
openApp().then(() =>
161+
NativeModules.HybridAppModule?.switchAccount({
162+
newDotCurrentAccountEmail: email,
163+
authToken: restrictedToken,
164+
policyID,
165+
accountID: String(previousAccountID),
166+
}),
167+
);
161168
});
162169
})
163170
.catch((error) => {
@@ -241,7 +248,14 @@ function disconnect() {
241248
NetworkStore.setAuthToken(response?.authToken ?? null);
242249

243250
confirmReadyToOpenApp();
244-
openApp().then(() => NativeModules.HybridAppModule?.switchAccount(requesterEmail, authToken, '', ''));
251+
openApp().then(() =>
252+
NativeModules.HybridAppModule?.switchAccount({
253+
newDotCurrentAccountEmail: requesterEmail,
254+
authToken,
255+
policyID: '',
256+
accountID: '',
257+
}),
258+
);
245259
});
246260
})
247261
.catch((error) => {

0 commit comments

Comments
 (0)