Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🍒 Cherry pick PR #56698 to staging 🍒 #57934

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1009010906
versionName "9.1.9-6"
versionCode 1009010907
versionName "9.1.9-7"
// Supported language variants must be declared here to avoid from being removed during the compilation.
// This also helps us to not include unnecessary language variants in the APK.
resConfigs "en", "es"
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>9.1.9.6</string>
<string>9.1.9.7</string>
<key>FullStory</key>
<dict>
<key>OrgId</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>9.1.9.6</string>
<string>9.1.9.7</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ios/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleShortVersionString</key>
<string>9.1.9</string>
<key>CFBundleVersion</key>
<string>9.1.9.6</string>
<string>9.1.9.7</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "9.1.9-6",
"version": "9.1.9-7",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
21 changes: 17 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ import type {Route} from './ROUTES';
import './setup/backgroundTask';
import {SplashScreenStateContextProvider} from './SplashScreenStateContext';

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

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

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

function App({url}: AppProps) {
function App({url, hybridAppSettings, timestamp}: AppProps) {
useDefaultDragAndDrop();
OnyxUpdateManager();

return (
<StrictModeWrapper>
<SplashScreenStateContextProvider>
<InitialURLContextProvider url={url}>
<InitialURLContextProvider
url={url}
hybridAppSettings={hybridAppSettings}
timestamp={timestamp}
>
<GestureHandlerRootView style={fill}>
<ComposeProviders
components={[
Expand Down Expand Up @@ -118,3 +129,5 @@ function App({url}: AppProps) {
App.displayName = 'App';

export default App;

export type {AppProps};
5 changes: 0 additions & 5 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6696,11 +6696,6 @@ const CONST = {
},
},

HYBRID_APP: {
REORDERING_REACT_NATIVE_ACTIVITY_TO_FRONT: 'reorderingReactNativeActivityToFront',
SINGLE_NEW_DOT_ENTRY: 'singleNewDotEntry',
},

MIGRATED_USER_WELCOME_MODAL: 'migratedUserWelcomeModal',

BASE_LIST_ITEM_TEST_ID: 'base-list-item-',
Expand Down
2 changes: 1 addition & 1 deletion src/components/BookTravelButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function BookTravelButton({text}: BookTravelButtonProps) {

// Close NewDot if it was opened only for Travel, as its purpose is now fulfilled.
Log.info('[HybridApp] Returning to OldDot after opening TravelDot');
NativeModules.HybridAppModule.closeReactNativeApp(false, false);
NativeModules.HybridAppModule.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: false});
setRootStatusBarEnabled(false);
})
?.catch(() => {
Expand Down
40 changes: 11 additions & 29 deletions src/components/InitialURLContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import React, {createContext, useEffect, useMemo, useState} from 'react';
import type {ReactNode} from 'react';
import {Linking} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import {signInAfterTransitionFromOldDot} from '@libs/actions/Session';
import Navigation from '@navigation/Navigation';
import type {AppProps} from '@src/App';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import {useSplashScreenStateContext} from '@src/SplashScreenStateContext';

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

type InitialURLContextProviderProps = {
/** URL passed to our top-level React Native component by HybridApp. Will always be undefined in "pure" NewDot builds. */
url?: Route | ValueOf<typeof CONST.HYBRID_APP>;

type InitialURLContextProviderProps = AppProps & {
/** Children passed to the context provider */
children: ReactNode;
};

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

useEffect(() => {
if (url !== CONST.HYBRID_APP.REORDERING_REACT_NATIVE_ACTIVITY_TO_FRONT) {
return;
}

if (splashScreenState !== CONST.BOOT_SPLASH_STATE.HIDDEN) {
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
Navigation.navigate(lastVisitedPath as Route);
}
}, [lastVisitedPath, setSplashScreenState, splashScreenState, url]);

useEffect(() => {
if (url === CONST.HYBRID_APP.REORDERING_REACT_NATIVE_ACTIVITY_TO_FRONT) {
return;
}

if (url) {
signInAfterTransitionFromOldDot(url).then((route) => {
setInitialURL(route);
if (url && hybridAppSettings) {
signInAfterTransitionFromOldDot(hybridAppSettings).then(() => {
setInitialURL(url);
if (splashScreenState === CONST.BOOT_SPLASH_STATE.HIDDEN) {
return;
}
setSplashScreenState(CONST.BOOT_SPLASH_STATE.READY_TO_BE_HIDDEN);
});
return;
}
Linking.getInitialURL().then((initURL) => {
setInitialURL(initURL as Route);
});
}, [setSplashScreenState, url]);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [url, hybridAppSettings, timestamp]);

const initialUrlContext = useMemo(
() => ({
Expand Down
13 changes: 6 additions & 7 deletions src/components/ScreenWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {UNSTABLE_usePreventRemove, useIsFocused, useNavigation, useRoute} from '@react-navigation/native';
import {UNSTABLE_usePreventRemove, useIsFocused, useNavigation} from '@react-navigation/native';
import type {ForwardedRef, ReactNode} from 'react';
import React, {createContext, forwardRef, useContext, useEffect, useMemo, useRef, useState} from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {Keyboard, NativeModules, PanResponder, View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import {PickerAvoidingView} from 'react-native-picker-select';
import type {EdgeInsets} from 'react-native-safe-area-context';
import useEnvironment from '@hooks/useEnvironment';
Expand All @@ -18,6 +19,7 @@ import type {ReportsSplitNavigatorParamList, RootNavigatorParamList} from '@libs
import addViewportResizeListener from '@libs/VisualViewport';
import toggleTestToolsModal from '@userActions/TestTool';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import CustomDevMenu from './CustomDevMenu';
import CustomStatusBarAndBackgroundContext from './CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext';
import FocusTrapForScreens from './FocusTrap/FocusTrapForScreen';
Expand Down Expand Up @@ -158,6 +160,7 @@ function ScreenWrapper(
// since Modals are drawn in separate native view hierarchy we should always add paddings
const ignoreInsetsConsumption = !useContext(ModalContext).default;
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);
const [isSingleNewDotEntry] = useOnyx(ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY);

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

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

UNSTABLE_usePreventRemove(shouldReturnToOldDot, () => {
NativeModules.HybridAppModule?.closeReactNativeApp(false, false);
UNSTABLE_usePreventRemove(isSingleNewDotEntry ?? false, () => {
NativeModules.HybridAppModule?.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: false});
setRootStatusBarEnabled(false);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ Onyx.connect({
},
});

let isSingleNewDotEntry: boolean | undefined;
Onyx.connect({
key: ONYXKEYS.IS_SINGLE_NEW_DOT_ENTRY,
callback: (value) => {
if (!value) {
return;
}
isSingleNewDotEntry = value;
},
});

function getLastUpdateIDAppliedToClient(): Promise<number> {
return new Promise((resolve) => {
Onyx.connect({
Expand Down Expand Up @@ -106,7 +117,7 @@ function navigateToReport({reportID, reportActionID}: ReportActionPushNotificati
try {
// When transitioning to the new experience via the singleNewDotEntry flow, the navigation
// is handled elsewhere. So we cancel here to prevent double navigation.
if (Navigation.getActiveRoute().includes(CONST.HYBRID_APP.SINGLE_NEW_DOT_ENTRY)) {
if (isSingleNewDotEntry) {
Log.info('[PushNotification] Not navigating because this is a singleNewDotEntry flow', false, {reportID, reportActionID});
return;
}
Expand Down
18 changes: 16 additions & 2 deletions src/libs/actions/Delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,14 @@ function connect(email: string) {

NetworkStore.setAuthToken(response?.restrictedToken ?? null);
confirmReadyToOpenApp();
openApp().then(() => NativeModules.HybridAppModule?.switchAccount(email, restrictedToken, policyID, String(previousAccountID)));
openApp().then(() =>
NativeModules.HybridAppModule?.switchAccount({
newDotCurrentAccountEmail: email,
authToken: restrictedToken,
policyID,
accountID: String(previousAccountID),
}),
);
});
})
.catch((error) => {
Expand Down Expand Up @@ -241,7 +248,14 @@ function disconnect() {
NetworkStore.setAuthToken(response?.authToken ?? null);

confirmReadyToOpenApp();
openApp().then(() => NativeModules.HybridAppModule?.switchAccount(requesterEmail, authToken, '', ''));
openApp().then(() =>
NativeModules.HybridAppModule?.switchAccount({
newDotCurrentAccountEmail: requesterEmail,
authToken,
policyID: '',
accountID: '',
}),
);
});
})
.catch((error) => {
Expand Down
Loading
Loading