Skip to content

Commit 9e85b9f

Browse files
authored
Merge pull request #51979 from ishpaul777/feat/51804
Re-direct to Classic when creating expenses for non-migrated users #51804
2 parents 3a72690 + 539de6e commit 9e85b9f

File tree

3 files changed

+69
-13
lines changed

3 files changed

+69
-13
lines changed

src/languages/en.ts

+4
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,10 @@ const translations = {
742742
listOfChats: 'List of chats',
743743
saveTheWorld: 'Save the world',
744744
tooltip: 'Get started here!',
745+
redirectToExpensifyClassicModal: {
746+
title: 'Coming soon',
747+
description: "We're fine-tuning a few more bits and pieces of New Expensify to accommodate your specific setup. In the meantime, head over to Expensify Classic.",
748+
},
745749
},
746750
allSettingsScreen: {
747751
subscription: 'Subscription',

src/languages/es.ts

+4
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,10 @@ const translations = {
736736
listOfChats: 'lista de chats',
737737
saveTheWorld: 'Salvar el mundo',
738738
tooltip: '¡Comienza aquí!',
739+
redirectToExpensifyClassicModal: {
740+
title: 'Próximamente',
741+
description: 'Estamos ajustando algunos detalles de New Expensify para adaptarla a tu configuración específica. Mientras tanto, dirígete a Expensify Classic.',
742+
},
739743
},
740744
allSettingsScreen: {
741745
subscription: 'Suscripcion',

src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx

+61-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {View} from 'react-native';
66
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
77
import {useOnyx} from 'react-native-onyx';
88
import type {SvgProps} from 'react-native-svg';
9+
import ConfirmModal from '@components/ConfirmModal';
910
import FloatingActionButton from '@components/FloatingActionButton';
1011
import * as Expensicons from '@components/Icon/Expensicons';
1112
import type {PopoverMenuItem} from '@components/PopoverMenu';
@@ -168,6 +169,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl
168169
const [hasSeenTrackTraining] = useOnyx(ONYXKEYS.NVP_HAS_SEEN_TRACK_TRAINING);
169170

170171
const [isCreateMenuActive, setIsCreateMenuActive] = useState(false);
172+
const [modalVisible, setModalVisible] = useState(false);
171173
const fabRef = useRef<HTMLDivElement>(null);
172174
const {windowHeight} = useWindowDimensions();
173175
const {shouldUseNarrowLayout} = useResponsiveLayout();
@@ -183,6 +185,18 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl
183185
const [hasSeenTour = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
184186
selector: hasSeenTourSelector,
185187
});
188+
/**
189+
* There are scenarios where users who have not yet had their group workspace-chats in NewDot (isPolicyExpenseChatEnabled). In those scenarios, things can get confusing if they try to submit/track expenses. To address this, we block them from Creating, Tracking, Submitting expenses from NewDot if they are:
190+
* 1. on at least one group policy
191+
* 2. none of the group policies they are a member of have isPolicyExpenseChatEnabled=true
192+
*/
193+
const shouldRedirectToExpensifyClassic = useMemo(() => {
194+
const groupPolicies = Object.values(allPolicies ?? {}).filter((policy) => ReportUtils.isGroupPolicy(policy?.type ?? ''));
195+
if (groupPolicies.length === 0) {
196+
return false;
197+
}
198+
return !groupPolicies.some((policy) => !!policy?.isPolicyExpenseChatEnabled);
199+
}, [allPolicies]);
186200

187201
const quickActionAvatars = useMemo(() => {
188202
if (quickActionReport) {
@@ -348,15 +362,20 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl
348362
{
349363
icon: getIconForAction(CONST.IOU.TYPE.CREATE),
350364
text: translate('iou.createExpense'),
365+
shouldCallAfterModalHide: shouldRedirectToExpensifyClassic,
351366
onSelected: () =>
352-
interceptAnonymousUser(() =>
367+
interceptAnonymousUser(() => {
368+
if (shouldRedirectToExpensifyClassic) {
369+
setModalVisible(true);
370+
return;
371+
}
353372
IOU.startMoneyRequest(
354373
CONST.IOU.TYPE.CREATE,
355374
// When starting to create an expense from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used
356375
// for all of the routes in the creation flow.
357376
ReportUtils.generateReportID(),
358-
),
359-
),
377+
);
378+
}),
360379
},
361380
];
362381
}
@@ -367,16 +386,21 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl
367386
{
368387
icon: getIconForAction(CONST.IOU.TYPE.TRACK),
369388
text: translate('iou.trackExpense'),
389+
shouldCallAfterModalHide: shouldRedirectToExpensifyClassic,
370390
onSelected: () => {
371-
interceptAnonymousUser(() =>
391+
if (shouldRedirectToExpensifyClassic) {
392+
setModalVisible(true);
393+
return;
394+
}
395+
interceptAnonymousUser(() => {
372396
IOU.startMoneyRequest(
373397
CONST.IOU.TYPE.TRACK,
374398
// When starting to create a track expense from the global FAB, we need to retrieve selfDM reportID.
375399
// If it doesn't exist, we generate a random optimistic reportID and use it for all of the routes in the creation flow.
376400
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
377401
ReportUtils.findSelfDMReportID() || ReportUtils.generateReportID(),
378-
),
379-
);
402+
);
403+
});
380404
if (!hasSeenTrackTraining && !isOffline) {
381405
setTimeout(() => {
382406
Navigation.navigate(ROUTES.TRACK_TRAINING_MODAL);
@@ -389,18 +413,24 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl
389413
{
390414
icon: getIconForAction(CONST.IOU.TYPE.REQUEST),
391415
text: translate('iou.submitExpense'),
416+
shouldCallAfterModalHide: shouldRedirectToExpensifyClassic,
392417
onSelected: () =>
393-
interceptAnonymousUser(() =>
418+
interceptAnonymousUser(() => {
419+
if (shouldRedirectToExpensifyClassic) {
420+
setModalVisible(true);
421+
return;
422+
}
423+
394424
IOU.startMoneyRequest(
395425
CONST.IOU.TYPE.SUBMIT,
396426
// When starting to create an expense from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used
397427
// for all of the routes in the creation flow.
398428
ReportUtils.generateReportID(),
399-
),
400-
),
429+
);
430+
}),
401431
},
402432
];
403-
}, [canUseCombinedTrackSubmit, translate, selfDMReportID, hasSeenTrackTraining, isOffline]);
433+
}, [canUseCombinedTrackSubmit, translate, selfDMReportID, hasSeenTrackTraining, isOffline, shouldRedirectToExpensifyClassic]);
404434

405435
const quickActionMenuItems = useMemo(() => {
406436
// Define common properties in baseQuickAction
@@ -493,15 +523,21 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl
493523
{
494524
icon: Expensicons.InvoiceGeneric,
495525
text: translate('workspace.invoices.sendInvoice'),
526+
shouldCallAfterModalHide: shouldRedirectToExpensifyClassic,
496527
onSelected: () =>
497-
interceptAnonymousUser(() =>
528+
interceptAnonymousUser(() => {
529+
if (shouldRedirectToExpensifyClassic) {
530+
setModalVisible(true);
531+
return;
532+
}
533+
498534
IOU.startMoneyRequest(
499535
CONST.IOU.TYPE.INVOICE,
500536
// When starting to create an invoice from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used
501537
// for all of the routes in the creation flow.
502538
ReportUtils.generateReportID(),
503-
),
504-
),
539+
);
540+
}),
505541
},
506542
]
507543
: []),
@@ -548,6 +584,18 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl
548584
withoutOverlay
549585
anchorRef={fabRef}
550586
/>
587+
<ConfirmModal
588+
prompt={translate('sidebarScreen.redirectToExpensifyClassicModal.description')}
589+
isVisible={modalVisible}
590+
onConfirm={() => {
591+
setModalVisible(false);
592+
Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX);
593+
}}
594+
onCancel={() => setModalVisible(false)}
595+
title={translate('sidebarScreen.redirectToExpensifyClassicModal.title')}
596+
confirmText={translate('exitSurvey.goToExpensifyClassic')}
597+
cancelText={translate('common.cancel')}
598+
/>
551599
<FloatingActionButton
552600
accessibilityLabel={translate('sidebarScreen.fabNewChatExplained')}
553601
role={CONST.ROLE.BUTTON}

0 commit comments

Comments
 (0)