From b42e340a3c9fc926a96d79ea0c52292a5f295f11 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Tue, 11 Nov 2025 23:38:17 +0700 Subject: [PATCH 1/4] Next button on Initial page reopens same page when Workflows settings are disabled --- .../home/sidebar/FloatingActionButtonAndPopover.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index c1daafa1cb3b..7a3645b9c6c2 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -305,7 +305,14 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref const quickActionReportID = policyChatForActivePolicy?.reportID ?? reportID; Tab.setSelectedTab(CONST.TAB.IOU_REQUEST_TYPE, CONST.IOU.REQUEST_TYPE.SCAN); - startMoneyRequest(CONST.IOU.TYPE.CREATE, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, !!policyChatForActivePolicy?.reportID, undefined, allTransactionDrafts); + startMoneyRequest( + policyChatForActivePolicy?.reportID ? CONST.IOU.TYPE.SUBMIT : CONST.IOU.TYPE.CREATE, + quickActionReportID, + CONST.IOU.REQUEST_TYPE.SCAN, + !!policyChatForActivePolicy?.reportID, + undefined, + allTransactionDrafts, + ); }); }, [policyChatForActivePolicy?.policyID, policyChatForActivePolicy?.reportID, reportID, allTransactionDrafts]); From af4937cd7595d8549a8854e02cbfe131f82dabdf Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Thu, 4 Dec 2025 21:56:15 +0700 Subject: [PATCH 2/4] Next button on Initial page reopens same page when Workflows settings are disabled --- tests/ui/FloatingReceiptButtonTest.tsx | 89 ++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tests/ui/FloatingReceiptButtonTest.tsx b/tests/ui/FloatingReceiptButtonTest.tsx index af24e8bc22f9..2777036945d0 100644 --- a/tests/ui/FloatingReceiptButtonTest.tsx +++ b/tests/ui/FloatingReceiptButtonTest.tsx @@ -1,9 +1,31 @@ import {NavigationContainer} from '@react-navigation/native'; import {cleanup, fireEvent, render, screen} from '@testing-library/react-native'; import React from 'react'; +import Onyx from 'react-native-onyx'; +import ComposeProviders from '@components/ComposeProviders'; import FloatingReceiptButton from '@components/FloatingReceiptButton'; +import {LocaleContextProvider} from '@components/LocaleContextProvider'; +import NavigationTabBar from '@components/Navigation/NavigationTabBar'; +import NAVIGATION_TABS from '@components/Navigation/NavigationTabBar/NAVIGATION_TABS'; +import OnyxListItemProvider from '@components/OnyxListItemProvider'; +import {SidebarOrderedReportsContextProvider} from '@hooks/useSidebarOrderedReports'; +import {startMoneyRequest} from '@libs/actions/IOU'; +import navigationRef from '@libs/Navigation/navigationRef'; import colors from '@styles/theme/colors'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import createRandomPolicy from '../utils/collections/policies'; +import {createPolicyExpenseChat} from '../utils/collections/reports'; +import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; + +jest.mock('@libs/actions/IOU', () => ({ + startMoneyRequest: jest.fn(), +})); + +jest.mock('@hooks/useResponsiveLayout', () => (): {shouldUseNarrowLayout: boolean} => ({shouldUseNarrowLayout: false})); + +const SS_EMAIL = 'testing@gmail.com'; +const SS_ACCOUNT_ID = 1; describe('FloatingReceiptButton hover', () => { const onPress = jest.fn(); @@ -45,3 +67,70 @@ describe('FloatingReceiptButton hover', () => { expect(container).not.toHaveStyle({backgroundColor: colors.greenHover}); }); }); + +describe('FloatingReceiptButton onPress', () => { + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + return waitForBatchedUpdates(); + }); + + beforeEach(async () => { + return jest.clearAllMocks(); + }); + + it('should call startMoneyRequest with CREATE iouType when there is no active policy', () => { + render( + + {}} + > + + + , + ); + + const floatingReceiptButton = screen.getByTestId('floating-receipt-button'); + expect(floatingReceiptButton).toBeVisible(); + + fireEvent.press(floatingReceiptButton); + + expect(startMoneyRequest).toHaveBeenCalled(); + const [[iouType]] = (startMoneyRequest as jest.MockedFunction).mock.calls; + expect(iouType).toEqual(CONST.IOU.TYPE.CREATE); + }); + + it('should call startMoneyRequest with SUBMIT iouType when there is an active policy', async () => { + const fakePolicy = {...createRandomPolicy(0, CONST.POLICY.TYPE.TEAM), isPolicyExpenseChatEnabled: true}; + const fakeReport = {...createPolicyExpenseChat(0), ownerAccountID: SS_ACCOUNT_ID}; + await Onyx.set(ONYXKEYS.SESSION, {email: SS_EMAIL, accountID: SS_ACCOUNT_ID}); + await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${fakePolicy.id}`, fakePolicy); + await Onyx.set(`${ONYXKEYS.NVP_ACTIVE_POLICY_ID}`, fakePolicy.id); + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${fakeReport.reportID}`, fakeReport); + + await waitForBatchedUpdates(); + + render( + + {}} + > + + + , + ); + + await waitForBatchedUpdates(); + + const floatingReceiptButton = screen.getByTestId('floating-receipt-button'); + expect(floatingReceiptButton).toBeVisible(); + + fireEvent.press(floatingReceiptButton); + + expect(startMoneyRequest).toHaveBeenCalled(); + const [[iouType, reportID]] = (startMoneyRequest as jest.MockedFunction).mock.calls; + expect(iouType).toEqual(CONST.IOU.TYPE.SUBMIT); + expect(reportID).toEqual(fakeReport.reportID); + }); +}); From f22e3c6b4ca07cfb161418ba9514e26136104189 Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Thu, 4 Dec 2025 22:31:56 +0700 Subject: [PATCH 3/4] Next button on Initial page reopens same page when Workflows settings are disabled --- .../BaseFloatingCameraButton.tsx | 9 ++- tests/ui/FloatingReceiptButtonTest.tsx | 58 ++++++++++++++++++- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx b/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx index 804f9fa3cb69..a5bbd991cacd 100644 --- a/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx +++ b/src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx @@ -60,7 +60,14 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) { const quickActionReportID = policyChatForActivePolicy?.reportID ?? reportID; Tab.setSelectedTab(CONST.TAB.IOU_REQUEST_TYPE, CONST.IOU.REQUEST_TYPE.SCAN); - startMoneyRequest(CONST.IOU.TYPE.CREATE, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, !!policyChatForActivePolicy?.reportID, undefined, allTransactionDrafts); + startMoneyRequest( + policyChatForActivePolicy?.reportID ? CONST.IOU.TYPE.SUBMIT : CONST.IOU.TYPE.CREATE, + quickActionReportID, + CONST.IOU.REQUEST_TYPE.SCAN, + !!policyChatForActivePolicy?.reportID, + undefined, + allTransactionDrafts, + ); }); }; diff --git a/tests/ui/FloatingReceiptButtonTest.tsx b/tests/ui/FloatingReceiptButtonTest.tsx index 2777036945d0..bbc69978276d 100644 --- a/tests/ui/FloatingReceiptButtonTest.tsx +++ b/tests/ui/FloatingReceiptButtonTest.tsx @@ -8,6 +8,7 @@ import {LocaleContextProvider} from '@components/LocaleContextProvider'; import NavigationTabBar from '@components/Navigation/NavigationTabBar'; import NAVIGATION_TABS from '@components/Navigation/NavigationTabBar/NAVIGATION_TABS'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import {SidebarOrderedReportsContextProvider} from '@hooks/useSidebarOrderedReports'; import {startMoneyRequest} from '@libs/actions/IOU'; import navigationRef from '@libs/Navigation/navigationRef'; @@ -22,11 +23,13 @@ jest.mock('@libs/actions/IOU', () => ({ startMoneyRequest: jest.fn(), })); -jest.mock('@hooks/useResponsiveLayout', () => (): {shouldUseNarrowLayout: boolean} => ({shouldUseNarrowLayout: false})); +jest.mock('@hooks/useResponsiveLayout', () => jest.fn()); const SS_EMAIL = 'testing@gmail.com'; const SS_ACCOUNT_ID = 1; +const mockedUseResponsiveLayout = useResponsiveLayout as jest.MockedFunction; + describe('FloatingReceiptButton hover', () => { const onPress = jest.fn(); @@ -79,7 +82,9 @@ describe('FloatingReceiptButton onPress', () => { }); it('should call startMoneyRequest with CREATE iouType when there is no active policy', () => { - render( + mockedUseResponsiveLayout.mockReturnValue({...CONST.NAVIGATION_TESTS.DEFAULT_USE_RESPONSIVE_LAYOUT_VALUE, shouldUseNarrowLayout: false}); + + const {rerender} = render( { expect(startMoneyRequest).toHaveBeenCalled(); const [[iouType]] = (startMoneyRequest as jest.MockedFunction).mock.calls; expect(iouType).toEqual(CONST.IOU.TYPE.CREATE); + + // render FloatingCameraButton component + mockedUseResponsiveLayout.mockReturnValue({...CONST.NAVIGATION_TESTS.DEFAULT_USE_RESPONSIVE_LAYOUT_VALUE, shouldUseNarrowLayout: true}); + rerender( + + {}} + > + + + , + ); + + const floatingCameraButton = screen.getByTestId('floating-camera-button'); + expect(floatingCameraButton).toBeVisible(); + + fireEvent.press(floatingCameraButton); + + expect(startMoneyRequest).toHaveBeenCalled(); + const [, [iouType1]] = (startMoneyRequest as jest.MockedFunction).mock.calls; + expect(iouType1).toEqual(CONST.IOU.TYPE.CREATE); }); it('should call startMoneyRequest with SUBMIT iouType when there is an active policy', async () => { + mockedUseResponsiveLayout.mockReturnValue({...CONST.NAVIGATION_TESTS.DEFAULT_USE_RESPONSIVE_LAYOUT_VALUE, shouldUseNarrowLayout: false}); + const fakePolicy = {...createRandomPolicy(0, CONST.POLICY.TYPE.TEAM), isPolicyExpenseChatEnabled: true}; const fakeReport = {...createPolicyExpenseChat(0), ownerAccountID: SS_ACCOUNT_ID}; await Onyx.set(ONYXKEYS.SESSION, {email: SS_EMAIL, accountID: SS_ACCOUNT_ID}); @@ -110,7 +139,7 @@ describe('FloatingReceiptButton onPress', () => { await waitForBatchedUpdates(); - render( + const {rerender} = render( { const [[iouType, reportID]] = (startMoneyRequest as jest.MockedFunction).mock.calls; expect(iouType).toEqual(CONST.IOU.TYPE.SUBMIT); expect(reportID).toEqual(fakeReport.reportID); + + // render FloatingCameraButton component + mockedUseResponsiveLayout.mockReturnValue({...CONST.NAVIGATION_TESTS.DEFAULT_USE_RESPONSIVE_LAYOUT_VALUE, shouldUseNarrowLayout: true}); + rerender( + + {}} + > + + + , + ); + + const floatingCameraButton = screen.getByTestId('floating-camera-button'); + expect(floatingCameraButton).toBeVisible(); + + fireEvent.press(floatingCameraButton); + + expect(startMoneyRequest).toHaveBeenCalled(); + const [, [iouType1, reportID1]] = (startMoneyRequest as jest.MockedFunction).mock.calls; + expect(iouType1).toEqual(CONST.IOU.TYPE.SUBMIT); + expect(reportID1).toEqual(fakeReport.reportID); }); }); From 0c772bfb2845144a9eafb6caac8db10feeb7dccf Mon Sep 17 00:00:00 2001 From: dmkt9 Date: Thu, 4 Dec 2025 23:11:24 +0700 Subject: [PATCH 4/4] fix lint --- src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 0ca68538e399..1e2d14143e55 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -271,6 +271,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref }, [isValidReport, quickActionAvatars, personalDetails, quickAction?.action]); const quickActionSubtitle = useMemo(() => { + // eslint-disable-next-line @typescript-eslint/no-deprecated return !hideQABSubtitle ? (getReportName(quickActionReport, quickActionPolicy, undefined, personalDetails) ?? translate('quickAction.updateDestination')) : ''; // eslint-disable-next-line react-compiler/react-compiler // eslint-disable-next-line react-hooks/exhaustive-deps @@ -474,6 +475,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref ...baseQuickAction, icon: Expensicons.ReceiptScan, text: translate('quickAction.scanReceipt'), + // eslint-disable-next-line @typescript-eslint/no-deprecated description: getReportName(policyChatForActivePolicy), shouldCallAfterModalHide: shouldUseNarrowLayout, onSelected,