From 460e4aa34c55256936afbd47d3a76c3156404ceb Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Mon, 4 Nov 2024 23:26:15 +0530 Subject: [PATCH 1/9] v1 changes --- .../FloatingActionButtonAndPopover.tsx | 67 +++++++++++++++---- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index a49b474b185e..f3caffa2a7a0 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -6,6 +6,7 @@ import {View} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import {useOnyx, withOnyx} from 'react-native-onyx'; import type {SvgProps} from 'react-native-svg'; +import ConfirmModal from '@components/ConfirmModal'; import FloatingActionButton from '@components/FloatingActionButton'; import * as Expensicons from '@components/Icon/Expensicons'; import type {PopoverMenuItem} from '@components/PopoverMenu'; @@ -28,6 +29,7 @@ import * as ReportUtils from '@libs/ReportUtils'; import * as SubscriptionUtils from '@libs/SubscriptionUtils'; import * as App from '@userActions/App'; import * as IOU from '@userActions/IOU'; +import * as Link from '@userActions/Link'; import * as Policy from '@userActions/Policy/Policy'; import * as Report from '@userActions/Report'; import * as Task from '@userActions/Task'; @@ -180,6 +182,7 @@ function FloatingActionButtonAndPopover( const {translate} = useLocalize(); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${quickActionReport?.reportID ?? -1}`); const [isCreateMenuActive, setIsCreateMenuActive] = useState(false); + const [modalVisible, setModalVisible] = useState(false); const fabRef = useRef(null); const {windowHeight} = useWindowDimensions(); const {shouldUseNarrowLayout} = useResponsiveLayout(); @@ -190,6 +193,14 @@ function FloatingActionButtonAndPopover( const {canUseSpotnanaTravel, canUseCombinedTrackSubmit} = usePermissions(); const canSendInvoice = useMemo(() => PolicyUtils.canSendInvoice(allPolicies as OnyxCollection, session?.email), [allPolicies, session?.email]); + const shouldRedirectToOD = useMemo(() => { + const groupPolicies = Object.values(allPolicies ?? {}).filter((policy) => ReportUtils.isGroupPolicy(policy?.type ?? '')); + if (groupPolicies.length === 0) { + return false; + } + return groupPolicies.every((policy) => !policy?.isPolicyExpenseChatEnabled); + }, [allPolicies]); + const quickActionAvatars = useMemo(() => { if (quickActionReport) { const avatars = ReportUtils.getIcons(quickActionReport, personalDetails); @@ -360,14 +371,18 @@ function FloatingActionButtonAndPopover( icon: getIconForAction(CONST.IOU.TYPE.CREATE), text: translate('iou.createExpense'), onSelected: () => - interceptAnonymousUser(() => + interceptAnonymousUser(() => { + if (shouldRedirectToOD) { + setModalVisible(true); + return; + } IOU.startMoneyRequest( CONST.IOU.TYPE.CREATE, // 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 // for all of the routes in the creation flow. ReportUtils.generateReportID(), - ), - ), + ); + }), }, ]; } @@ -379,15 +394,19 @@ function FloatingActionButtonAndPopover( icon: getIconForAction(CONST.IOU.TYPE.TRACK), text: translate('iou.trackExpense'), onSelected: () => { - interceptAnonymousUser(() => + if (shouldRedirectToOD) { + setModalVisible(true); + return; + } + interceptAnonymousUser(() => { IOU.startMoneyRequest( CONST.IOU.TYPE.TRACK, // When starting to create a track expense from the global FAB, we need to retrieve selfDM reportID. // If it doesn't exist, we generate a random optimistic reportID and use it for all of the routes in the creation flow. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing ReportUtils.findSelfDMReportID() || ReportUtils.generateReportID(), - ), - ); + ); + }); if (!hasSeenTrackTraining && !isOffline) { setTimeout(() => { Navigation.navigate(ROUTES.TRACK_TRAINING_MODAL); @@ -401,17 +420,22 @@ function FloatingActionButtonAndPopover( icon: getIconForAction(CONST.IOU.TYPE.REQUEST), text: translate('iou.submitExpense'), onSelected: () => - interceptAnonymousUser(() => + interceptAnonymousUser(() => { + if (shouldRedirectToOD) { + setModalVisible(true); + return; + } + IOU.startMoneyRequest( CONST.IOU.TYPE.SUBMIT, // 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 // for all of the routes in the creation flow. ReportUtils.generateReportID(), - ), - ), + ); + }), }, ]; - }, [canUseCombinedTrackSubmit, translate, selfDMReportID, hasSeenTrackTraining, isOffline]); + }, [canUseCombinedTrackSubmit, translate, selfDMReportID, hasSeenTrackTraining, isOffline, shouldRedirectToOD]); return ( @@ -434,14 +458,19 @@ function FloatingActionButtonAndPopover( icon: Expensicons.InvoiceGeneric, text: translate('workspace.invoices.sendInvoice'), onSelected: () => - interceptAnonymousUser(() => + interceptAnonymousUser(() => { + if (shouldRedirectToOD) { + setModalVisible(true); + return; + } + IOU.startMoneyRequest( CONST.IOU.TYPE.INVOICE, // 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 // for all of the routes in the creation flow. ReportUtils.generateReportID(), - ), - ), + ); + }), }, ] : []), @@ -497,6 +526,18 @@ function FloatingActionButtonAndPopover( withoutOverlay anchorRef={fabRef} /> + { + setModalVisible(false); + Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX) + }} + onCancel={() => setModalVisible(false)} + title="Your workspace is not ready for New Expensify" + confirmText={translate('exitSurvey.goToExpensifyClassic')} + cancelText={translate('common.cancel')} + /> Date: Mon, 4 Nov 2024 23:34:13 +0530 Subject: [PATCH 2/9] prettier diffs --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index f3caffa2a7a0..64f094cf2332 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -531,7 +531,7 @@ function FloatingActionButtonAndPopover( isVisible={modalVisible} onConfirm={() => { setModalVisible(false); - Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX) + Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX); }} onCancel={() => setModalVisible(false)} title="Your workspace is not ready for New Expensify" From 9861eed014155e3daca052676dfb31308a1934ea Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Wed, 6 Nov 2024 23:37:20 +0530 Subject: [PATCH 3/9] update copy --- src/languages/en.ts | 4 ++++ src/languages/es.ts | 5 +++++ .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 38b11e9fea38..506cdd4a7903 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -740,6 +740,10 @@ const translations = { listOfChats: 'List of chats', saveTheWorld: 'Save the world', tooltip: 'Get started here!', + redirectToOldDotModal: { + title: '🚧 Under construction 🚧', + 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.", + }, }, allSettingsScreen: { subscription: 'Subscription', diff --git a/src/languages/es.ts b/src/languages/es.ts index 11a31c836add..1c12167c37a6 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -734,6 +734,11 @@ const translations = { listOfChats: 'lista de chats', saveTheWorld: 'Salvar el mundo', tooltip: '¡Comienza aquí!', + // TODO: ASK FOR TRANSLATIONS + redirectToOldDotModal: { + title: '🚧 Under construction 🚧', + 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.", + }, }, allSettingsScreen: { subscription: 'Suscripcion', diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index d0df88cd48df..676b6d17eef5 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -525,14 +525,14 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl anchorRef={fabRef} /> { setModalVisible(false); Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX); }} onCancel={() => setModalVisible(false)} - title="Your workspace is not ready for New Expensify" + title={translate('sidebarScreen.redirectToOldDotModal.title')} confirmText={translate('exitSurvey.goToExpensifyClassic')} cancelText={translate('common.cancel')} /> From c977d358793bc32f2e095e0d190fa26c573a412b Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 7 Nov 2024 01:06:42 +0530 Subject: [PATCH 4/9] fix trnslation --- src/languages/es.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 1c12167c37a6..9b215ee3fcc8 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -734,10 +734,9 @@ const translations = { listOfChats: 'lista de chats', saveTheWorld: 'Salvar el mundo', tooltip: '¡Comienza aquí!', - // TODO: ASK FOR TRANSLATIONS redirectToOldDotModal: { - title: '🚧 Under construction 🚧', - 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.", + title: '🚧 En construcción 🚧', + description: 'Estamos ajustando algunos detalles de New Expensify para adaptarla a tu configuración específica. Mientras tanto, dirígete a Expensify Classic.', }, }, allSettingsScreen: { From 826b51c70aea696ca59b75e990e19d09843ea747 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Thu, 7 Nov 2024 02:57:40 +0530 Subject: [PATCH 5/9] fix modal hide --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 676b6d17eef5..56a812d73ec8 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -353,6 +353,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl { icon: getIconForAction(CONST.IOU.TYPE.CREATE), text: translate('iou.createExpense'), + shouldCallAfterModalHide: shouldRedirectToOD, onSelected: () => interceptAnonymousUser(() => { if (shouldRedirectToOD) { @@ -376,6 +377,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl { icon: getIconForAction(CONST.IOU.TYPE.TRACK), text: translate('iou.trackExpense'), + shouldCallAfterModalHide: shouldRedirectToOD, onSelected: () => { if (shouldRedirectToOD) { setModalVisible(true); @@ -402,6 +404,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl { icon: getIconForAction(CONST.IOU.TYPE.REQUEST), text: translate('iou.submitExpense'), + shouldCallAfterModalHide: shouldRedirectToOD, onSelected: () => interceptAnonymousUser(() => { if (shouldRedirectToOD) { From 2436a60f0f5733b8bb2f696b2457f52405a6d132 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 9 Nov 2024 18:40:36 +0530 Subject: [PATCH 6/9] review comments --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 066fea5bacdd..f27d8a0a7029 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -191,7 +191,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl if (groupPolicies.length === 0) { return false; } - return groupPolicies.every((policy) => !policy?.isPolicyExpenseChatEnabled); + return !groupPolicies.some((policy) => policy?.isPolicyExpenseChatEnabled === true); }, [allPolicies]); const quickActionAvatars = useMemo(() => { @@ -529,6 +529,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl { icon: Expensicons.InvoiceGeneric, text: translate('workspace.invoices.sendInvoice'), + shouldCallAfterModalHide: shouldRedirectToOD, onSelected: () => interceptAnonymousUser(() => { if (shouldRedirectToOD) { From a48bd916d08f09c71151b8cfdf7752d27c88ab30 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Sat, 9 Nov 2024 18:48:11 +0530 Subject: [PATCH 7/9] fix copy --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1f8750c46277..002b727fdbfb 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -743,7 +743,7 @@ const translations = { saveTheWorld: 'Save the world', tooltip: 'Get started here!', redirectToOldDotModal: { - title: '🚧 Under construction 🚧', + title: 'Coming soon', 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.", }, }, diff --git a/src/languages/es.ts b/src/languages/es.ts index 31216318b1bb..0f9197c6855c 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -737,7 +737,7 @@ const translations = { saveTheWorld: 'Salvar el mundo', tooltip: '¡Comienza aquí!', redirectToOldDotModal: { - title: '🚧 En construcción 🚧', + title: 'Próximamente', description: 'Estamos ajustando algunos detalles de New Expensify para adaptarla a tu configuración específica. Mientras tanto, dirígete a Expensify Classic.', }, }, From 1aae8726df5c8576b0b7ce23290670d7fa556f44 Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Mon, 11 Nov 2024 22:14:04 +0530 Subject: [PATCH 8/9] handles legacy isPolicyExpenseChatEnabled --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 4609e8f3f22a..8fc55928e230 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -191,7 +191,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl if (groupPolicies.length === 0) { return false; } - return !groupPolicies.some((policy) => policy?.isPolicyExpenseChatEnabled === true); + return !groupPolicies.some((policy) => !!policy?.isPolicyExpenseChatEnabled); }, [allPolicies]); const quickActionAvatars = useMemo(() => { From 539de6e9de74be5241464856c2d88ada82ca67ec Mon Sep 17 00:00:00 2001 From: Ishpaul Singh Date: Tue, 12 Nov 2024 00:18:44 +0530 Subject: [PATCH 9/9] review comment changes --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- .../FloatingActionButtonAndPopover.tsx | 30 +++++++++++-------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 0b2a0d67e464..574e6be196f9 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -742,7 +742,7 @@ const translations = { listOfChats: 'List of chats', saveTheWorld: 'Save the world', tooltip: 'Get started here!', - redirectToOldDotModal: { + redirectToExpensifyClassicModal: { title: 'Coming soon', 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.", }, diff --git a/src/languages/es.ts b/src/languages/es.ts index 4f5aaabd6efc..b0a8f910b6cb 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -736,7 +736,7 @@ const translations = { listOfChats: 'lista de chats', saveTheWorld: 'Salvar el mundo', tooltip: '¡Comienza aquí!', - redirectToOldDotModal: { + redirectToExpensifyClassicModal: { title: 'Próximamente', description: 'Estamos ajustando algunos detalles de New Expensify para adaptarla a tu configuración específica. Mientras tanto, dirígete a Expensify Classic.', }, diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 8fc55928e230..03378e5e46f7 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -185,8 +185,12 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl const [hasSeenTour = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, { selector: hasSeenTourSelector, }); - - const shouldRedirectToOD = useMemo(() => { + /** + * 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: + * 1. on at least one group policy + * 2. none of the group policies they are a member of have isPolicyExpenseChatEnabled=true + */ + const shouldRedirectToExpensifyClassic = useMemo(() => { const groupPolicies = Object.values(allPolicies ?? {}).filter((policy) => ReportUtils.isGroupPolicy(policy?.type ?? '')); if (groupPolicies.length === 0) { return false; @@ -368,10 +372,10 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl { icon: getIconForAction(CONST.IOU.TYPE.CREATE), text: translate('iou.createExpense'), - shouldCallAfterModalHide: shouldRedirectToOD, + shouldCallAfterModalHide: shouldRedirectToExpensifyClassic, onSelected: () => interceptAnonymousUser(() => { - if (shouldRedirectToOD) { + if (shouldRedirectToExpensifyClassic) { setModalVisible(true); return; } @@ -392,9 +396,9 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl { icon: getIconForAction(CONST.IOU.TYPE.TRACK), text: translate('iou.trackExpense'), - shouldCallAfterModalHide: shouldRedirectToOD, + shouldCallAfterModalHide: shouldRedirectToExpensifyClassic, onSelected: () => { - if (shouldRedirectToOD) { + if (shouldRedirectToExpensifyClassic) { setModalVisible(true); return; } @@ -419,10 +423,10 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl { icon: getIconForAction(CONST.IOU.TYPE.REQUEST), text: translate('iou.submitExpense'), - shouldCallAfterModalHide: shouldRedirectToOD, + shouldCallAfterModalHide: shouldRedirectToExpensifyClassic, onSelected: () => interceptAnonymousUser(() => { - if (shouldRedirectToOD) { + if (shouldRedirectToExpensifyClassic) { setModalVisible(true); return; } @@ -436,7 +440,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl }), }, ]; - }, [canUseCombinedTrackSubmit, translate, selfDMReportID, hasSeenTrackTraining, isOffline, shouldRedirectToOD]); + }, [canUseCombinedTrackSubmit, translate, selfDMReportID, hasSeenTrackTraining, isOffline, shouldRedirectToExpensifyClassic]); const quickActionMenuItems = useMemo(() => { // Define common properties in baseQuickAction @@ -529,10 +533,10 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl { icon: Expensicons.InvoiceGeneric, text: translate('workspace.invoices.sendInvoice'), - shouldCallAfterModalHide: shouldRedirectToOD, + shouldCallAfterModalHide: shouldRedirectToExpensifyClassic, onSelected: () => interceptAnonymousUser(() => { - if (shouldRedirectToOD) { + if (shouldRedirectToExpensifyClassic) { setModalVisible(true); return; } @@ -591,14 +595,14 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl anchorRef={fabRef} /> { setModalVisible(false); Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX); }} onCancel={() => setModalVisible(false)} - title={translate('sidebarScreen.redirectToOldDotModal.title')} + title={translate('sidebarScreen.redirectToExpensifyClassicModal.title')} confirmText={translate('exitSurvey.goToExpensifyClassic')} cancelText={translate('common.cancel')} />