Skip to content
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
5 changes: 0 additions & 5 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ function canUseDefaultRooms(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.DEFAULT_ROOMS) || canUseAllBetas(betas);
}

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);
Expand Down Expand Up @@ -93,7 +89,6 @@ function canUseNewDotSplits(betas: OnyxEntry<Beta[]>): boolean {
export default {
canUseDefaultRooms,
canUseLinkPreviews,
canUseSpotnanaTravel,
isBlockedFromSpotnanaTravel,
isTravelVerified,
canUseNetSuiteUSATax,
Expand Down
19 changes: 5 additions & 14 deletions src/pages/Travel/MyTripsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React from 'react';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import CONFIG from '@src/CONFIG';
import ManageTrips from './ManageTrips';

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

return (
<ScreenWrapper
Expand All @@ -19,16 +15,11 @@ function MyTripsPage() {
testID={MyTripsPage.displayName}
shouldShowOfflineIndicatorInWideScreen
>
<FullPageNotFoundView
shouldForceFullScreen
shouldShow={!canUseSpotnanaTravel && !CONFIG.IS_HYBRID_APP}
>
<HeaderWithBackButton
title={translate('travel.header')}
shouldShowBackButton
/>
<ManageTrips />
</FullPageNotFoundView>
<HeaderWithBackButton
title={translate('travel.header')}
shouldShowBackButton
/>
<ManageTrips />
</ScreenWrapper>
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Travel/TravelTerms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ type TravelTermsPageProps = StackScreenProps<TravelNavigatorParamList, typeof SC
function TravelTerms({route}: TravelTermsPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
const {isBlockedFromSpotnanaTravel} = usePermissions();
const [hasAcceptedTravelTerms, setHasAcceptedTravelTerms] = useState(false);
const [errorMessage, setErrorMessage] = useState('');
const [travelProvisioning] = useOnyx(ONYXKEYS.TRAVEL_PROVISIONING);
const [travelProvisioning] = useOnyx(ONYXKEYS.TRAVEL_PROVISIONING, {canBeMissing: true});
const isLoading = travelProvisioning?.isLoading;
const domain = route.params.domain === CONST.TRAVEL.DEFAULT_DOMAIN ? undefined : route.params.domain;

Expand Down Expand Up @@ -81,7 +81,7 @@ function TravelTerms({route}: TravelTermsPageProps) {
shouldEnableMaxHeight
testID={TravelTerms.displayName}
>
<FullPageNotFoundView shouldShow={!CONFIG.IS_HYBRID_APP && (!canUseSpotnanaTravel || isBlockedFromSpotnanaTravel)}>
<FullPageNotFoundView shouldShow={!CONFIG.IS_HYBRID_APP && isBlockedFromSpotnanaTravel}>
<HeaderWithBackButton
title={translate('travel.termsAndConditions.header')}
onBackButtonPress={() => Navigation.goBack()}
Expand Down
14 changes: 7 additions & 7 deletions src/pages/Travel/TripDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const {canUseSpotnanaTravel, isBlockedFromSpotnanaTravel} = usePermissions();
const {isBlockedFromSpotnanaTravel} = usePermissions();
const {isOffline} = useNetwork();

const [isModifyTripLoading, setIsModifyTripLoading] = useState(false);
const [isTripSupportLoading, setIsTripSupportLoading] = useState(false);

const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${route.params.transactionID}`);
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 [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${route.params.transactionID}`, {canBeMissing: true});
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`, {canBeMissing: true});
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`, {canBeMissing: true});

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 = getTripReservationIcon(reservation?.type);
const [travelerPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: (personalDetails) => pickTravelerPersonalDetails(personalDetails, reservation)});
const [travelerPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: (personalDetails) => pickTravelerPersonalDetails(personalDetails, reservation), canBeMissing: true});

return (
<ScreenWrapper
Expand All @@ -67,7 +67,7 @@ function TripDetailsPage({route}: TripDetailsPageProps) {
>
<FullPageNotFoundView
shouldForceFullScreen
shouldShow={!reservation || (!CONFIG.IS_HYBRID_APP && (!canUseSpotnanaTravel || isBlockedFromSpotnanaTravel))}
shouldShow={!reservation || (!CONFIG.IS_HYBRID_APP && isBlockedFromSpotnanaTravel)}
>
<HeaderWithBackButton
title={reservationType ? `${translate(`travel.${reservationType}`)} ${translate('common.details').toLowerCase()}` : translate('common.details')}
Expand Down
6 changes: 2 additions & 4 deletions src/pages/Travel/TripSummaryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {ReservationView} from '@components/ReportActionItem/TripDetailsView';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import type {TravelNavigatorParamList} from '@libs/Navigation/types';
import CONFIG from '@src/CONFIG';
import * as TripReservationUtils from '@src/libs/TripReservationUtils';
Expand All @@ -19,9 +18,8 @@ type TripSummaryPageProps = StackScreenProps<TravelNavigatorParamList, typeof SC

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

const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${route.params.transactionID}`);
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${route.params.transactionID}`, {canBeMissing: true});
const reservationsData: TripReservationUtils.ReservationData[] = TripReservationUtils.getReservationsFromTripTransactions(transaction ? [transaction] : []);

return (
Expand All @@ -34,7 +32,7 @@ function TripSummaryPage({route}: TripSummaryPageProps) {
>
<FullPageNotFoundView
shouldForceFullScreen
shouldShow={reservationsData.length === 0 || (!canUseSpotnanaTravel && !CONFIG.IS_HYBRID_APP)}
shouldShow={reservationsData.length === 0 || !CONFIG.IS_HYBRID_APP}
>
<HeaderWithBackButton
title={translate(`travel.tripDetails`)}
Expand Down
20 changes: 9 additions & 11 deletions src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
const primaryContactMethod = primaryLogin ?? session?.email ?? '';
const [travelSettings] = useOnyx(ONYXKEYS.NVP_TRAVEL_SETTINGS, {canBeMissing: true});

const {canUseSpotnanaTravel, canUseTableReportView} = usePermissions();
const {canUseTableReportView} = usePermissions();
const canSendInvoice = useMemo(() => canSendInvoicePolicyUtils(allPolicies as OnyxCollection<OnyxTypes.Policy>, session?.email), [allPolicies, session?.email]);
const isValidReport = !(isEmptyObject(quickActionReport) || isArchivedReport(reportNameValuePairs));
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});
Expand Down Expand Up @@ -471,16 +471,14 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
},
]
: []),
...(canUseSpotnanaTravel
? [
{
icon: Expensicons.Suitcase,
text: translate('travel.bookTravel'),
rightIcon: isTravelEnabled ? Expensicons.NewWindow : undefined,
onSelected: () => interceptAnonymousUser(() => openTravel()),
},
]
: []),
...[
{
icon: Expensicons.Suitcase,
text: translate('travel.bookTravel'),
rightIcon: isTravelEnabled ? Expensicons.NewWindow : undefined,
onSelected: () => interceptAnonymousUser(() => openTravel()),
},
],
...(!hasSeenTour
? [
{
Expand Down
4 changes: 1 addition & 3 deletions src/pages/workspace/WorkspaceOverviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import useCardFeeds from '@hooks/useCardFeeds';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import usePayAndDowngrade from '@hooks/usePayAndDowngrade';
import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeIllustrations from '@hooks/useThemeIllustrations';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -57,7 +56,6 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
const {translate} = useLocalize();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const illustrations = useThemeIllustrations();
const {canUseSpotnanaTravel} = usePermissions();

const backTo = route.params.backTo;
const [currencyList = {}] = useOnyx(ONYXKEYS.CURRENCY_LIST, {canBeMissing: true});
Expand Down Expand Up @@ -346,7 +344,7 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
/>
</View>
</OfflineWithFeedback>
{!!canUseSpotnanaTravel && shouldShowAddress && (
{shouldShowAddress && (
<OfflineWithFeedback pendingAction={policy?.pendingFields?.address}>
<View>
<MenuItemWithTopDescription
Expand Down