Skip to content

Commit a0d88dd

Browse files
authored
Merge pull request #56973 from Expensify/stites-preventTravelIfBlocked
Add preventSpotnanaTravel beta and prevent those users from seeing travel related content
2 parents 76b1507 + 7c8a8db commit a0d88dd

7 files changed

+24
-17
lines changed

src/CONST.ts

+1
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ const CONST = {
738738
DEFAULT_ROOMS: 'defaultRooms',
739739
P2P_DISTANCE_REQUESTS: 'p2pDistanceRequests',
740740
SPOTNANA_TRAVEL: 'spotnanaTravel',
741+
PREVENT_SPOTNANA_TRAVEL: 'preventSpotnanaTravel',
741742
REPORT_FIELDS_FEATURE: 'reportFieldsFeature',
742743
NETSUITE_USA_TAX: 'netsuiteUsaTax',
743744
COMBINED_TRACK_SUBMIT: 'combinedTrackSubmit',

src/libs/Permissions.ts

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ function canUseSpotnanaTravel(betas: OnyxEntry<Beta[]>): boolean {
1414
return !!betas?.includes(CONST.BETAS.SPOTNANA_TRAVEL) || canUseAllBetas(betas);
1515
}
1616

17+
function isBlockedFromSpotnanaTravel(betas: OnyxEntry<Beta[]>): boolean {
18+
// Don't check for all betas or nobody can use test travel on dev
19+
return !!betas?.includes(CONST.BETAS.PREVENT_SPOTNANA_TRAVEL);
20+
}
21+
1722
function canUseNetSuiteUSATax(betas: OnyxEntry<Beta[]>): boolean {
1823
return !!betas?.includes(CONST.BETAS.NETSUITE_USA_TAX) || canUseAllBetas(betas);
1924
}
@@ -53,6 +58,7 @@ export default {
5358
canUseDefaultRooms,
5459
canUseLinkPreviews,
5560
canUseSpotnanaTravel,
61+
isBlockedFromSpotnanaTravel,
5662
canUseNetSuiteUSATax,
5763
canUsePerDiem,
5864
canUseMergeAccounts,

src/pages/Travel/MyTripsPage.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import ManageTrips from './ManageTrips';
99

1010
function MyTripsPage() {
1111
const {translate} = useLocalize();
12-
const {canUseSpotnanaTravel} = usePermissions();
12+
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
1313

1414
return (
1515
<ScreenWrapper
@@ -21,7 +21,7 @@ function MyTripsPage() {
2121
>
2222
<FullPageNotFoundView
2323
shouldForceFullScreen
24-
shouldShow={!canUseSpotnanaTravel && !NativeModules.HybridAppModule}
24+
shouldShow={(!canUseSpotnanaTravel && !NativeModules.HybridAppModule) || (isBlockedFromSpotnanaTravel && !NativeModules.HybridAppModule)}
2525
>
2626
<HeaderWithBackButton
2727
title={translate('travel.header')}

src/pages/Travel/TravelTerms.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type TravelTermsPageProps = StackScreenProps<TravelNavigatorParamList, typeof SC
2828
function TravelTerms({route}: TravelTermsPageProps) {
2929
const styles = useThemeStyles();
3030
const {translate} = useLocalize();
31-
const {canUseSpotnanaTravel} = usePermissions();
31+
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
3232
const [hasAcceptedTravelTerms, setHasAcceptedTravelTerms] = useState(false);
3333
const [errorMessage, setErrorMessage] = useState('');
3434
const [travelProvisioning] = useOnyx(ONYXKEYS.TRAVEL_PROVISIONING);
@@ -80,7 +80,7 @@ function TravelTerms({route}: TravelTermsPageProps) {
8080
shouldEnableMaxHeight
8181
testID={TravelTerms.displayName}
8282
>
83-
<FullPageNotFoundView shouldShow={!canUseSpotnanaTravel && !NativeModules.HybridAppModule}>
83+
<FullPageNotFoundView shouldShow={(!canUseSpotnanaTravel && !NativeModules.HybridAppModule) || (isBlockedFromSpotnanaTravel && !NativeModules.HybridAppModule)}>
8484
<HeaderWithBackButton
8585
title={translate('travel.termsAndConditions.header')}
8686
onBackButtonPress={() => Navigation.goBack()}

src/pages/Travel/TripDetailsPage.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import useStyleUtils from '@hooks/useStyleUtils';
1616
import useTheme from '@hooks/useTheme';
1717
import useThemeStyles from '@hooks/useThemeStyles';
1818
import type {TravelNavigatorParamList} from '@libs/Navigation/types';
19-
import * as ReportUtils from '@libs/ReportUtils';
20-
import * as TripReservationUtils from '@libs/TripReservationUtils';
21-
import * as Link from '@userActions/Link';
19+
import {getTripIDFromTransactionParentReportID} from '@libs/ReportUtils';
20+
import {getTripReservationIcon} from '@libs/TripReservationUtils';
21+
import {openTravelDotLink} from '@userActions/Link';
2222
import CONST from '@src/CONST';
2323
import ONYXKEYS from '@src/ONYXKEYS';
2424
import type SCREENS from '@src/SCREENS';
@@ -40,7 +40,7 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
4040
const styles = useThemeStyles();
4141
const StyleUtils = useStyleUtils();
4242
const {translate} = useLocalize();
43-
const {canUseSpotnanaTravel} = usePermissions();
43+
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
4444
const {isOffline} = useNetwork();
4545

4646
const [isModifyTripLoading, setIsModifyTripLoading] = useState(false);
@@ -51,10 +51,10 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
5151
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID ?? CONST.DEFAULT_NUMBER_ID}`);
5252
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID ?? CONST.DEFAULT_NUMBER_ID}`);
5353

54-
const tripID = ReportUtils.getTripIDFromTransactionParentReportID(parentReport?.reportID);
54+
const tripID = getTripIDFromTransactionParentReportID(parentReport?.reportID);
5555
const reservationType = transaction?.receipt?.reservationList?.at(route.params.reservationIndex ?? 0)?.type;
5656
const reservation = transaction?.receipt?.reservationList?.at(route.params.reservationIndex ?? 0);
57-
const reservationIcon = TripReservationUtils.getTripReservationIcon(reservation?.type);
57+
const reservationIcon = getTripReservationIcon(reservation?.type);
5858
const [travelerPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: (personalDetails) => pickTravelerPersonalDetails(personalDetails, reservation)});
5959

6060
return (
@@ -67,7 +67,7 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
6767
>
6868
<FullPageNotFoundView
6969
shouldForceFullScreen
70-
shouldShow={!reservation || (!canUseSpotnanaTravel && !NativeModules.HybridAppModule)}
70+
shouldShow={!reservation || (!canUseSpotnanaTravel && !NativeModules.HybridAppModule) || (isBlockedFromSpotnanaTravel && !NativeModules.HybridAppModule)}
7171
>
7272
<HeaderWithBackButton
7373
title={reservationType ? `${translate(`travel.${reservationType}`)} ${translate('common.details').toLowerCase()}` : translate('common.details')}
@@ -112,7 +112,7 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
112112
shouldShowRightIcon
113113
onPress={() => {
114114
setIsModifyTripLoading(true);
115-
Link.openTravelDotLink(activePolicyID, CONST.TRIP_ID_PATH(tripID))?.finally(() => {
115+
openTravelDotLink(activePolicyID, CONST.TRIP_ID_PATH(tripID))?.finally(() => {
116116
setIsModifyTripLoading(false);
117117
});
118118
}}
@@ -128,7 +128,7 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
128128
shouldShowRightIcon
129129
onPress={() => {
130130
setIsTripSupportLoading(true);
131-
Link.openTravelDotLink(activePolicyID, CONST.TRIP_SUPPORT)?.finally(() => {
131+
openTravelDotLink(activePolicyID, CONST.TRIP_SUPPORT)?.finally(() => {
132132
setIsTripSupportLoading(false);
133133
});
134134
}}

src/pages/Travel/TripSummaryPage.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type TripSummaryPageProps = StackScreenProps<TravelNavigatorParamList, typeof SC
1919

2020
function TripSummaryPage({route}: TripSummaryPageProps) {
2121
const {translate} = useLocalize();
22-
const {canUseSpotnanaTravel} = usePermissions();
22+
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
2323

2424
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${route.params.transactionID}`);
2525
const reservationsData: TripReservationUtils.ReservationData[] = TripReservationUtils.getReservationsFromTripTransactions(transaction ? [transaction] : []);
@@ -34,7 +34,7 @@ function TripSummaryPage({route}: TripSummaryPageProps) {
3434
>
3535
<FullPageNotFoundView
3636
shouldForceFullScreen
37-
shouldShow={reservationsData.length === 0 || (!canUseSpotnanaTravel && !NativeModules.HybridAppModule)}
37+
shouldShow={reservationsData.length === 0 || (!canUseSpotnanaTravel && !NativeModules.HybridAppModule) || (isBlockedFromSpotnanaTravel && !NativeModules.HybridAppModule)}
3838
>
3939
<HeaderWithBackButton
4040
title={translate(`travel.tripDetails`)}

src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
190190
const prevIsFocused = usePrevious(isFocused);
191191
const {isOffline} = useNetwork();
192192

193-
const {canUseSpotnanaTravel} = usePermissions();
193+
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
194194
const canSendInvoice = useMemo(() => canSendInvoicePolicyUtils(allPolicies as OnyxCollection<OnyxTypes.Policy>, session?.email), [allPolicies, session?.email]);
195195
const isValidReport = !(isEmptyObject(quickActionReport) || isArchivedReport(reportNameValuePairs));
196196
const {environment} = useEnvironment();
@@ -485,7 +485,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
485485
},
486486
]
487487
: []),
488-
...(canUseSpotnanaTravel
488+
...(canUseSpotnanaTravel && !isBlockedFromSpotnanaTravel
489489
? [
490490
{
491491
icon: Expensicons.Suitcase,

0 commit comments

Comments
 (0)