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

Add preventSpotnanaTravel beta and prevent those users from seeing travel related content #56973

Merged
merged 4 commits into from
Feb 17, 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
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ const CONST = {
DEFAULT_ROOMS: 'defaultRooms',
P2P_DISTANCE_REQUESTS: 'p2pDistanceRequests',
SPOTNANA_TRAVEL: 'spotnanaTravel',
PREVENT_SPOTNANA_TRAVEL: 'preventSpotnanaTravel',
REPORT_FIELDS_FEATURE: 'reportFieldsFeature',
NETSUITE_USA_TAX: 'netsuiteUsaTax',
COMBINED_TRACK_SUBMIT: 'combinedTrackSubmit',
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ function canUseSpotnanaTravel(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.SPOTNANA_TRAVEL) || canUseAllBetas(betas);
}

function isBlockedFromSpotnanaTravel(betas: OnyxEntry<Beta[]>): boolean {
// Don't check for all betas or nobody can use test travel on dev
return !!betas?.includes(CONST.BETAS.PREVENT_SPOTNANA_TRAVEL);
}

function canUseNetSuiteUSATax(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.NETSUITE_USA_TAX) || canUseAllBetas(betas);
}
Expand Down Expand Up @@ -53,6 +58,7 @@ export default {
canUseDefaultRooms,
canUseLinkPreviews,
canUseSpotnanaTravel,
isBlockedFromSpotnanaTravel,
canUseNetSuiteUSATax,
canUsePerDiem,
canUseMergeAccounts,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Travel/MyTripsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ManageTrips from './ManageTrips';

function MyTripsPage() {
const {translate} = useLocalize();
const {canUseSpotnanaTravel} = usePermissions();
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();

return (
<ScreenWrapper
Expand All @@ -21,7 +21,7 @@ function MyTripsPage() {
>
<FullPageNotFoundView
shouldForceFullScreen
shouldShow={!canUseSpotnanaTravel && !NativeModules.HybridAppModule}
shouldShow={(!canUseSpotnanaTravel && !NativeModules.HybridAppModule) || (isBlockedFromSpotnanaTravel && !NativeModules.HybridAppModule)}
>
<HeaderWithBackButton
title={translate('travel.header')}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Travel/TravelTerms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type TravelTermsPageProps = StackScreenProps<TravelNavigatorParamList, typeof SC
function TravelTerms({route}: TravelTermsPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {canUseSpotnanaTravel} = usePermissions();
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
const [hasAcceptedTravelTerms, setHasAcceptedTravelTerms] = useState(false);
const [errorMessage, setErrorMessage] = useState('');
const [travelProvisioning] = useOnyx(ONYXKEYS.TRAVEL_PROVISIONING);
Expand Down Expand Up @@ -80,7 +80,7 @@ function TravelTerms({route}: TravelTermsPageProps) {
shouldEnableMaxHeight
testID={TravelTerms.displayName}
>
<FullPageNotFoundView shouldShow={!canUseSpotnanaTravel && !NativeModules.HybridAppModule}>
<FullPageNotFoundView shouldShow={(!canUseSpotnanaTravel && !NativeModules.HybridAppModule) || (isBlockedFromSpotnanaTravel && !NativeModules.HybridAppModule)}>
<HeaderWithBackButton
title={translate('travel.termsAndConditions.header')}
onBackButtonPress={() => Navigation.goBack()}
Expand Down
18 changes: 9 additions & 9 deletions src/pages/Travel/TripDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import type {TravelNavigatorParamList} from '@libs/Navigation/types';
import * as ReportUtils from '@libs/ReportUtils';
import * as TripReservationUtils from '@libs/TripReservationUtils';
import * as Link from '@userActions/Link';
import {getTripIDFromTransactionParentReportID} from '@libs/ReportUtils';
import {getTripReservationIcon} from '@libs/TripReservationUtils';
import {openTravelDotLink} from '@userActions/Link';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
Expand All @@ -40,7 +40,7 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const {canUseSpotnanaTravel} = usePermissions();
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
const {isOffline} = useNetwork();

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

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

return (
Expand All @@ -67,7 +67,7 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
>
<FullPageNotFoundView
shouldForceFullScreen
shouldShow={!reservation || (!canUseSpotnanaTravel && !NativeModules.HybridAppModule)}
shouldShow={!reservation || (!canUseSpotnanaTravel && !NativeModules.HybridAppModule) || (isBlockedFromSpotnanaTravel && !NativeModules.HybridAppModule)}
>
<HeaderWithBackButton
title={reservationType ? `${translate(`travel.${reservationType}`)} ${translate('common.details').toLowerCase()}` : translate('common.details')}
Expand Down Expand Up @@ -112,7 +112,7 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
shouldShowRightIcon
onPress={() => {
setIsModifyTripLoading(true);
Link.openTravelDotLink(activePolicyID, CONST.TRIP_ID_PATH(tripID))?.finally(() => {
openTravelDotLink(activePolicyID, CONST.TRIP_ID_PATH(tripID))?.finally(() => {
setIsModifyTripLoading(false);
});
}}
Expand All @@ -128,7 +128,7 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
shouldShowRightIcon
onPress={() => {
setIsTripSupportLoading(true);
Link.openTravelDotLink(activePolicyID, CONST.TRIP_SUPPORT)?.finally(() => {
openTravelDotLink(activePolicyID, CONST.TRIP_SUPPORT)?.finally(() => {
setIsTripSupportLoading(false);
});
}}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Travel/TripSummaryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type TripSummaryPageProps = StackScreenProps<TravelNavigatorParamList, typeof SC

function TripSummaryPage({route}: TripSummaryPageProps) {
const {translate} = useLocalize();
const {canUseSpotnanaTravel} = usePermissions();
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();

const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${route.params.transactionID}`);
const reservationsData: TripReservationUtils.ReservationData[] = TripReservationUtils.getReservationsFromTripTransactions(transaction ? [transaction] : []);
Expand All @@ -34,7 +34,7 @@ function TripSummaryPage({route}: TripSummaryPageProps) {
>
<FullPageNotFoundView
shouldForceFullScreen
shouldShow={reservationsData.length === 0 || (!canUseSpotnanaTravel && !NativeModules.HybridAppModule)}
shouldShow={reservationsData.length === 0 || (!canUseSpotnanaTravel && !NativeModules.HybridAppModule) || (isBlockedFromSpotnanaTravel && !NativeModules.HybridAppModule)}
>
<HeaderWithBackButton
title={translate(`travel.tripDetails`)}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
const prevIsFocused = usePrevious(isFocused);
const {isOffline} = useNetwork();

const {canUseSpotnanaTravel} = usePermissions();
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
const canSendInvoice = useMemo(() => canSendInvoicePolicyUtils(allPolicies as OnyxCollection<OnyxTypes.Policy>, session?.email), [allPolicies, session?.email]);
const isValidReport = !(isEmptyObject(quickActionReport) || isArchivedReport(reportNameValuePairs));
const {environment} = useEnvironment();
Expand Down Expand Up @@ -485,7 +485,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
},
]
: []),
...(canUseSpotnanaTravel
...(canUseSpotnanaTravel && !isBlockedFromSpotnanaTravel
? [
{
icon: Expensicons.Suitcase,
Expand Down
Loading