Skip to content

Commit 97f63bb

Browse files
committed
Merge branch 'main' of https://github.com/Expensify/App into fix/64799/negative-sign-expense
2 parents 519dbcd + e766c7f commit 97f63bb

21 files changed

Lines changed: 258 additions & 112 deletions

File tree

src/CONST/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,6 @@ const CONST = {
642642
CUSTOM_RULES: 'customRules',
643643
GLOBAL_REIMBURSEMENTS_ON_ND: 'globalReimbursementsOnND',
644644
IS_TRAVEL_VERIFIED: 'isTravelVerified',
645-
MULTI_LEVEL_TAGS: 'multiLevelTags',
646645
NEWDOT_MULTI_FILES_DRAG_AND_DROP: 'newDotMultiFilesDragAndDrop',
647646
NEWDOT_MULTI_SCAN: 'newDotMultiScan',
648647
PLAID_COMPANY_CARDS: 'plaidCompanyCards',

src/ROUTES.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,10 @@ const ROUTES = {
19191919
getRoute: (backTo?: string) => getUrlWithBackToParam('change-workspace-educational', backTo),
19201920
},
19211921
TRAVEL_MY_TRIPS: 'travel',
1922+
TRAVEL_DOT_LINK_WEB_VIEW: {
1923+
route: 'travel-dot-link',
1924+
getRoute: (token: string, isTestAccount?: boolean) => `travel-dot-link?token=${token}&isTestAccount=${isTestAccount}` as const,
1925+
},
19221926
TRAVEL_TCS: {
19231927
route: 'travel/terms/:domain/accept',
19241928
getRoute: (domain: string, backTo?: string) => getUrlWithBackToParam(`travel/terms/${domain}/accept`, backTo),
@@ -2581,7 +2585,10 @@ const ROUTES = {
25812585
getRoute: (reportID: string) => `r/${reportID}/schedule-call/confirmation` as const,
25822586
},
25832587

2584-
TEST_TOOLS_MODAL: 'test-tools',
2588+
TEST_TOOLS_MODAL: {
2589+
route: 'test-tools',
2590+
getRoute: (backTo?: string) => getUrlWithBackToParam('test-tools' as const, backTo),
2591+
},
25852592
} as const;
25862593

25872594
/**

src/SCREENS.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const SCREENS = {
3535
DOMAIN_PERMISSION_INFO: 'Travel_DomainPermissionInfo',
3636
PUBLIC_DOMAIN_ERROR: 'Travel_PublicDomainError',
3737
WORKSPACE_ADDRESS: 'Travel_WorkspaceAddress',
38+
TRAVEL_DOT_LINK_WEB_VIEW: 'Travel_DotLinkWebView',
3839
},
3940
SEARCH: {
4041
ROOT: 'Search_Root',

src/components/BookTravelButton.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ import usePermissions from '@hooks/usePermissions';
88
import usePolicy from '@hooks/usePolicy';
99
import useStyleUtils from '@hooks/useStyleUtils';
1010
import useThemeStyles from '@hooks/useThemeStyles';
11-
import {openTravelDotLink} from '@libs/actions/Link';
1211
import {cleanupTravelProvisioningSession, requestTravelAccess} from '@libs/actions/Travel';
13-
import Log from '@libs/Log';
1412
import Navigation from '@libs/Navigation/Navigation';
13+
import {openTravelDotLink} from '@libs/openTravelDotLink';
1514
import {getActivePolicies, getAdminsPrivateEmailDomains, isPaidGroupPolicy} from '@libs/PolicyUtils';
1615
import colors from '@styles/theme/colors';
17-
import closeReactNativeApp from '@userActions/HybridApp';
18-
import CONFIG from '@src/CONFIG';
1916
import CONST from '@src/CONST';
2017
import ONYXKEYS from '@src/ONYXKEYS';
2118
import ROUTES from '@src/ROUTES';
@@ -68,9 +65,6 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
6865
const {login: currentUserLogin} = useCurrentUserPersonalDetails();
6966
const activePolicies = getActivePolicies(policies, currentUserLogin);
7067
const groupPaidPolicies = activePolicies.filter((activePolicy) => activePolicy.type !== CONST.POLICY.TYPE.PERSONAL && isPaidGroupPolicy(activePolicy));
71-
// Flag indicating whether NewDot was launched exclusively for Travel,
72-
// e.g., when the user selects "Trips" from the Expensify Classic menu in HybridApp.
73-
const [wasNewDotLaunchedJustForTravel] = useOnyx(ONYXKEYS.HYBRID_APP, {selector: (hybridApp) => hybridApp?.isSingleNewDotEntry, canBeMissing: false});
7468

7569
const hidePreventionModal = () => setPreventionModalVisibility(false);
7670
const hideVerificationModal = () => setVerificationModalVisibility(false);
@@ -125,21 +119,7 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
125119

126120
const isPolicyProvisioned = policy?.travelSettings?.spotnanaCompanyID ?? policy?.travelSettings?.associatedTravelDomainAccountID;
127121
if (policy?.travelSettings?.hasAcceptedTerms ?? (travelSettings?.hasAcceptedTerms && isPolicyProvisioned)) {
128-
openTravelDotLink(policy?.id)
129-
?.then(() => {
130-
// When a user selects "Trips" in the Expensify Classic menu, the HybridApp opens the ManageTrips page in NewDot.
131-
// The wasNewDotLaunchedJustForTravel flag indicates if NewDot was launched solely for this purpose.
132-
if (!CONFIG.IS_HYBRID_APP || !wasNewDotLaunchedJustForTravel) {
133-
return;
134-
}
135-
136-
// Close NewDot if it was opened only for Travel, as its purpose is now fulfilled.
137-
Log.info('[HybridApp] Returning to OldDot after opening TravelDot');
138-
closeReactNativeApp({shouldSignOut: false, shouldSetNVP: false});
139-
})
140-
?.catch(() => {
141-
setErrorMessage(translate('travel.errorMessage'));
142-
});
122+
openTravelDotLink(policy?.id);
143123
} else if (isPolicyProvisioned) {
144124
navigateToAcceptTerms(CONST.TRAVEL.DEFAULT_DOMAIN);
145125
} else if (!isBetaEnabled(CONST.BETAS.IS_TRAVEL_VERIFIED)) {
@@ -175,7 +155,6 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
175155
styles.link,
176156
StyleUtils,
177157
translate,
178-
wasNewDotLaunchedJustForTravel,
179158
isUserValidated,
180159
]);
181160

src/components/TestToolsModalPage.tsx

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,84 @@
1+
import {useRoute} from '@react-navigation/native';
12
import React from 'react';
23
import {View} from 'react-native';
34
import useIsAuthenticated from '@hooks/useIsAuthenticated';
45
import useLocalize from '@hooks/useLocalize';
56
import useOnyx from '@hooks/useOnyx';
67
import useThemeStyles from '@hooks/useThemeStyles';
78
import useWindowDimensions from '@hooks/useWindowDimensions';
9+
import navigateAfterInteraction from '@libs/Navigation/navigateAfterInteraction';
10+
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
811
import Navigation from '@navigation/Navigation';
12+
import type {TestToolsModalModalNavigatorParamList} from '@navigation/types';
13+
import toggleTestToolsModal from '@userActions/TestTool';
914
import ONYXKEYS from '@src/ONYXKEYS';
1015
import ROUTES from '@src/ROUTES';
16+
import type SCREENS from '@src/SCREENS';
1117
import Button from './Button';
18+
import PressableWithoutFeedback from './Pressable/PressableWithoutFeedback';
1219
import RecordTroubleshootDataToolMenu from './RecordTroubleshootDataToolMenu';
1320
import SafeAreaConsumer from './SafeAreaConsumer';
1421
import ScrollView from './ScrollView';
1522
import TestToolMenu from './TestToolMenu';
1623
import TestToolRow from './TestToolRow';
1724
import Text from './Text';
1825

19-
function getRouteBasedOnAuthStatus(isAuthenticated: boolean, activeRoute: string) {
26+
function getRouteBasedOnAuthStatus(isAuthenticated: boolean, activeRoute?: string) {
2027
return isAuthenticated ? ROUTES.SETTINGS_CONSOLE.getRoute(activeRoute) : ROUTES.PUBLIC_CONSOLE_DEBUG.getRoute(activeRoute);
2128
}
2229

2330
function TestToolsModalPage() {
2431
const {windowHeight} = useWindowDimensions();
2532
const styles = useThemeStyles();
2633
const {translate} = useLocalize();
27-
const activeRoute = Navigation.getActiveRoute();
34+
const route = useRoute<PlatformStackRouteProp<TestToolsModalModalNavigatorParamList, typeof SCREENS.TEST_TOOLS_MODAL.ROOT>>();
35+
const backTo = route.params?.backTo;
2836
const [shouldStoreLogs = false] = useOnyx(ONYXKEYS.SHOULD_STORE_LOGS, {canBeMissing: true});
2937
const isAuthenticated = useIsAuthenticated();
30-
const route = getRouteBasedOnAuthStatus(isAuthenticated, activeRoute);
38+
39+
// If no backTo param is provided (direct access to /test-tools),
40+
// use home route as a default backTo param for console navigation
41+
const effectiveBackTo = backTo ?? ROUTES.HOME;
42+
const consoleRoute = getRouteBasedOnAuthStatus(isAuthenticated, effectiveBackTo);
3143

3244
const maxHeight = windowHeight;
3345

3446
return (
3547
<SafeAreaConsumer>
3648
{({safeAreaPaddingBottomStyle}) => (
3749
<View style={[{maxHeight}, styles.h100, styles.defaultModalContainer, safeAreaPaddingBottomStyle]}>
38-
<ScrollView style={[styles.flex1, styles.flexGrow1, styles.ph5]}>
39-
<Text
40-
style={[styles.textLabelSupporting, styles.mt5, styles.mb3]}
41-
numberOfLines={1}
50+
<ScrollView
51+
style={[styles.flex1, styles.ph5]}
52+
contentContainerStyle={styles.flexGrow1}
53+
>
54+
<PressableWithoutFeedback
55+
accessible={false}
56+
style={[styles.cursorDefault]}
4257
>
43-
{translate('initialSettingsPage.troubleshoot.releaseOptions')}
44-
</Text>
45-
<RecordTroubleshootDataToolMenu />
46-
{!!shouldStoreLogs && (
47-
<TestToolRow title={translate('initialSettingsPage.troubleshoot.debugConsole')}>
48-
<Button
49-
small
50-
text={translate('initialSettingsPage.debugConsole.viewConsole')}
51-
onPress={() => {
52-
Navigation.navigate(route);
53-
}}
54-
/>
55-
</TestToolRow>
56-
)}
57-
<TestToolMenu />
58+
<Text
59+
style={[styles.textLabelSupporting, styles.mt5, styles.mb3]}
60+
numberOfLines={1}
61+
>
62+
{translate('initialSettingsPage.troubleshoot.releaseOptions')}
63+
</Text>
64+
<RecordTroubleshootDataToolMenu />
65+
{!!shouldStoreLogs && (
66+
<TestToolRow title={translate('initialSettingsPage.troubleshoot.debugConsole')}>
67+
<Button
68+
small
69+
text={translate('initialSettingsPage.debugConsole.viewConsole')}
70+
onPress={() => {
71+
// Close the test tools modal first, then navigate to console page
72+
toggleTestToolsModal();
73+
navigateAfterInteraction(() => {
74+
Navigation.navigate(consoleRoute);
75+
});
76+
}}
77+
/>
78+
</TestToolRow>
79+
)}
80+
<TestToolMenu />
81+
</PressableWithoutFeedback>
5882
</ScrollView>
5983
</View>
6084
)}

src/libs/Navigation/AppNavigator/AuthScreens.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
760760
cardStyle: {
761761
...StyleUtils.getBackgroundColorWithOpacityStyle(theme.overlay, 0.72),
762762
},
763+
animation: InternalPlatformAnimations.FADE,
763764
},
764765
}}
765766
component={TestToolsModalNavigator}

src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator<MoneyRequestNa
131131

132132
const TravelModalStackNavigator = createModalStackNavigator<TravelNavigatorParamList>({
133133
[SCREENS.TRAVEL.MY_TRIPS]: () => require<ReactComponentModule>('../../../../pages/Travel/MyTripsPage').default,
134+
[SCREENS.TRAVEL.TRAVEL_DOT_LINK_WEB_VIEW]: () => require<ReactComponentModule>('../../../../pages/Travel/TravelDotLinkWebview').default,
134135
[SCREENS.TRAVEL.TCS]: () => require<ReactComponentModule>('../../../../pages/Travel/TravelTerms').default,
135136
[SCREENS.TRAVEL.UPGRADE]: () => require<ReactComponentModule>('../../../../pages/Travel/TravelUpgrade').default,
136137
[SCREENS.TRAVEL.TRIP_SUMMARY]: () => require<ReactComponentModule>('../../../../pages/Travel/TripSummaryPage').default,

src/libs/Navigation/AppNavigator/Navigators/TestToolsModalNavigator.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import useIsAuthenticated from '@hooks/useIsAuthenticated';
99
import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
1010
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1111
import useThemeStyles from '@hooks/useThemeStyles';
12+
import blurActiveElement from '@libs/Accessibility/blurActiveElement';
1213
import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator';
1314
import type {TestToolsModalModalNavigatorParamList} from '@libs/Navigation/types';
1415
import toggleTestToolsModal from '@userActions/TestTool';
@@ -25,6 +26,8 @@ function TestToolsModalNavigator() {
2526
const isAuthenticated = useIsAuthenticated();
2627

2728
const handleOuterClick = useCallback(() => {
29+
// Release focus from any focused element before closing the modal
30+
blurActiveElement();
2831
requestAnimationFrame(() => {
2932
toggleTestToolsModal();
3033
});
@@ -34,17 +37,16 @@ function TestToolsModalNavigator() {
3437
e.stopPropagation();
3538
}, []);
3639

37-
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ESCAPE, () => toggleTestToolsModal(), {shouldBubble: true});
40+
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ESCAPE, () => toggleTestToolsModal(), {shouldBubble: false});
3841

3942
return (
4043
<NoDropZone>
4144
<Overlay />
4245
<PressableWithoutFeedback
4346
ref={outerViewRef}
4447
onPress={handleOuterClick}
45-
style={[styles.getTestToolsNavigatorOuterView(shouldUseNarrowLayout), styles.cursorDefault]}
46-
accessibilityRole="button"
47-
accessibilityLabel="button"
48+
style={[styles.getTestToolsNavigatorOuterView(shouldUseNarrowLayout)]}
49+
accessible={false}
4850
>
4951
<FocusTrapForScreens>
5052
<View

src/libs/Navigation/AppNavigator/PublicScreens.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function PublicScreens() {
8787
cardStyle: {
8888
...StyleUtils.getBackgroundColorWithOpacityStyle(theme.overlay, 0.72),
8989
},
90+
animation: InternalPlatformAnimations.FADE,
9091
},
9192
}}
9293
component={TestToolsModalNavigator}

src/libs/Navigation/linkingConfig/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
14851485
[SCREENS.RIGHT_MODAL.TRAVEL]: {
14861486
screens: {
14871487
[SCREENS.TRAVEL.MY_TRIPS]: ROUTES.TRAVEL_MY_TRIPS,
1488+
[SCREENS.TRAVEL.TRAVEL_DOT_LINK_WEB_VIEW]: ROUTES.TRAVEL_DOT_LINK_WEB_VIEW.route,
14881489
[SCREENS.TRAVEL.UPGRADE]: ROUTES.TRAVEL_UPGRADE.route,
14891490
[SCREENS.TRAVEL.TCS]: ROUTES.TRAVEL_TCS.route,
14901491
[SCREENS.TRAVEL.TRIP_SUMMARY]: ROUTES.TRAVEL_TRIP_SUMMARY.route,
@@ -1803,7 +1804,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
18031804
[NAVIGATORS.TEST_TOOLS_MODAL_NAVIGATOR]: {
18041805
screens: {
18051806
[SCREENS.TEST_TOOLS_MODAL.ROOT]: {
1806-
path: ROUTES.TEST_TOOLS_MODAL,
1807+
path: ROUTES.TEST_TOOLS_MODAL.route,
18071808
exact: true,
18081809
},
18091810
},

0 commit comments

Comments
 (0)