From 07d28e4c47e7a3cf50c751d546bcaf1fce8fc062 Mon Sep 17 00:00:00 2001 From: Ryan Teguh Date: Thu, 24 Jul 2025 20:19:49 +0800 Subject: [PATCH 1/7] Fix: User is navigated to the other report the expense was moved to --- .../iou/request/step/IOURequestEditReport.tsx | 14 +++++++++++++- .../iou/request/step/IOURequestStepReport.tsx | 9 ++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestEditReport.tsx b/src/pages/iou/request/step/IOURequestEditReport.tsx index 3843f711b2f2..0366fff4c922 100644 --- a/src/pages/iou/request/step/IOURequestEditReport.tsx +++ b/src/pages/iou/request/step/IOURequestEditReport.tsx @@ -3,7 +3,9 @@ import {useSearchContext} from '@components/Search/SearchContext'; import type {ListItem} from '@components/SelectionList/types'; import useOnyx from '@hooks/useOnyx'; import {changeTransactionsReport} from '@libs/actions/Transaction'; +import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; import Navigation from '@libs/Navigation/Navigation'; +import {getReportTransactions} from '@libs/ReportUtils'; import ONYXKEYS from '@src/ONYXKEYS'; import type SCREENS from '@src/SCREENS'; import IOURequestEditReportCommon from './IOURequestEditReportCommon'; @@ -30,9 +32,19 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) { return; } + const allReportTransactions = getReportTransactions(reportID); + const isMovingAllExpenses = selectedTransactionIDs.length === allReportTransactions.length; + changeTransactionsReport(selectedTransactionIDs, item.value); clearSelectedTransactions(true); - Navigation.dismissModalWithReport({reportID: item.value}); + + if (isMovingAllExpenses && !isSearchTopmostFullScreenRoute()) { + // If moving all expenses, navigate to destination report since original becomes empty (except for Reports page, to maintain the behavior to show the empty report state) + Navigation.dismissModalWithReport({reportID: item.value}); + } else { + // If only moving some expenses, stay on original report + Navigation.dismissModal(); + } }; return ( diff --git a/src/pages/iou/request/step/IOURequestStepReport.tsx b/src/pages/iou/request/step/IOURequestStepReport.tsx index 26e8e1e4cb42..7b061c50c1b2 100644 --- a/src/pages/iou/request/step/IOURequestStepReport.tsx +++ b/src/pages/iou/request/step/IOURequestStepReport.tsx @@ -2,7 +2,9 @@ import React from 'react'; import type {ListItem} from '@components/SelectionList/types'; import useOnyx from '@hooks/useOnyx'; import {changeTransactionsReport, setTransactionReport} from '@libs/actions/Transaction'; -import Navigation from '@libs/Navigation/Navigation'; +import isReportOpenInRHP from '@libs/Navigation/helpers/isReportOpenInRHP'; +import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; +import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; import {getReportOrDraftReport} from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -33,6 +35,11 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { const handleGoBackWithReportID = (id: string) => { if (isEditing) { + const isFromReportPage = isReportOpenInRHP(navigationRef.getRootState()); + if (isFromReportPage || isSearchTopmostFullScreenRoute()) { + Navigation.dismissModal(); + return; + } Navigation.dismissModalWithReport({reportID: id}); } else { Navigation.goBack(backTo); From 26d0cd00eeb0447033e13eec18fd5e1b3407bd06 Mon Sep 17 00:00:00 2001 From: Ryan Teguh Date: Thu, 24 Jul 2025 21:38:37 +0800 Subject: [PATCH 2/7] Fix: User is navigated to the other report the expense was moved to --- src/components/MoneyReportHeader.tsx | 5 +++++ src/pages/iou/request/step/IOURequestEditReport.tsx | 12 +----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 862b82edd25f..41f08e421187 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -926,6 +926,11 @@ function MoneyReportHeader({ const isMobileSelectionModeEnabled = useMobileSelectionMode(); if (isMobileSelectionModeEnabled) { + // If mobile selection mode is enabled but only one transaction remains, turn it off + if (transactions.length === 1) { + turnOffMobileSelectionMode(); + } + return ( Date: Thu, 24 Jul 2025 21:40:42 +0800 Subject: [PATCH 3/7] ESLint fix --- src/pages/iou/request/step/IOURequestEditReport.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestEditReport.tsx b/src/pages/iou/request/step/IOURequestEditReport.tsx index 25510c51b0c9..9a6c879276c9 100644 --- a/src/pages/iou/request/step/IOURequestEditReport.tsx +++ b/src/pages/iou/request/step/IOURequestEditReport.tsx @@ -3,9 +3,7 @@ import {useSearchContext} from '@components/Search/SearchContext'; import type {ListItem} from '@components/SelectionList/types'; import useOnyx from '@hooks/useOnyx'; import {changeTransactionsReport} from '@libs/actions/Transaction'; -import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; import Navigation from '@libs/Navigation/Navigation'; -import {getReportTransactions} from '@libs/ReportUtils'; import ONYXKEYS from '@src/ONYXKEYS'; import type SCREENS from '@src/SCREENS'; import IOURequestEditReportCommon from './IOURequestEditReportCommon'; From 0e592a1656842b58efc9f58b6a33ac88411ce0a4 Mon Sep 17 00:00:00 2001 From: Ryan Teguh Date: Thu, 24 Jul 2025 23:05:19 +0800 Subject: [PATCH 4/7] Fix: User is navigated to the other report the expense was moved to --- src/components/MoneyReportHeader.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 41f08e421187..c45c1b852eb9 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -926,8 +926,8 @@ function MoneyReportHeader({ const isMobileSelectionModeEnabled = useMobileSelectionMode(); if (isMobileSelectionModeEnabled) { - // If mobile selection mode is enabled but only one transaction remains, turn it off - if (transactions.length === 1) { + // If mobile selection mode is enabled but only one or no transactions remain, turn it off + if (transactions.length <= 1) { turnOffMobileSelectionMode(); } From da5b81a6da7fa77ec047e146dbeecd06ca9528cf Mon Sep 17 00:00:00 2001 From: Ryan Teguh Date: Mon, 28 Jul 2025 19:47:21 +0800 Subject: [PATCH 5/7] remove isReportOpenInRHP check --- src/pages/iou/request/step/IOURequestStepReport.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepReport.tsx b/src/pages/iou/request/step/IOURequestStepReport.tsx index 7b061c50c1b2..274a7f3a8849 100644 --- a/src/pages/iou/request/step/IOURequestStepReport.tsx +++ b/src/pages/iou/request/step/IOURequestStepReport.tsx @@ -2,9 +2,7 @@ import React from 'react'; import type {ListItem} from '@components/SelectionList/types'; import useOnyx from '@hooks/useOnyx'; import {changeTransactionsReport, setTransactionReport} from '@libs/actions/Transaction'; -import isReportOpenInRHP from '@libs/Navigation/helpers/isReportOpenInRHP'; -import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute'; -import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; +import Navigation from '@libs/Navigation/Navigation'; import {getReportOrDraftReport} from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -35,12 +33,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { const handleGoBackWithReportID = (id: string) => { if (isEditing) { - const isFromReportPage = isReportOpenInRHP(navigationRef.getRootState()); - if (isFromReportPage || isSearchTopmostFullScreenRoute()) { - Navigation.dismissModal(); - return; - } - Navigation.dismissModalWithReport({reportID: id}); + Navigation.dismissModal(); } else { Navigation.goBack(backTo); } From b8c889a397577589043020115e1acde64754691a Mon Sep 17 00:00:00 2001 From: Ryan Teguh Date: Mon, 28 Jul 2025 19:55:57 +0800 Subject: [PATCH 6/7] ESLint fix --- src/pages/iou/request/step/IOURequestStepReport.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepReport.tsx b/src/pages/iou/request/step/IOURequestStepReport.tsx index 274a7f3a8849..a4149e2e4861 100644 --- a/src/pages/iou/request/step/IOURequestStepReport.tsx +++ b/src/pages/iou/request/step/IOURequestStepReport.tsx @@ -31,7 +31,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { const isFromGlobalCreate = !!transaction?.isFromGlobalCreate; const reportOrDraftReport = getReportOrDraftReport(reportIDFromRoute); - const handleGoBackWithReportID = (id: string) => { + const handleGoBackWithReportID = () => { if (isEditing) { Navigation.dismissModal(); } else { @@ -88,7 +88,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { changeTransactionsReport([transaction.transactionID], item.value); } - handleGoBackWithReportID(item.value); + handleGoBackWithReportID(); }; const selectReport = (item: TransactionGroupListItem) => { @@ -100,7 +100,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { // Early return for same report selection if (isSameReport) { - handleGoBackWithReportID(item.value); + handleGoBackWithReportID(); return; } From 13158cf8c976add2e96fa5adff68d9f04d4f5923 Mon Sep 17 00:00:00 2001 From: Ryan Teguh Date: Mon, 28 Jul 2025 22:17:56 +0800 Subject: [PATCH 7/7] minor change --- src/pages/iou/request/step/IOURequestStepReport.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepReport.tsx b/src/pages/iou/request/step/IOURequestStepReport.tsx index a4149e2e4861..c536981d08a6 100644 --- a/src/pages/iou/request/step/IOURequestStepReport.tsx +++ b/src/pages/iou/request/step/IOURequestStepReport.tsx @@ -31,7 +31,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { const isFromGlobalCreate = !!transaction?.isFromGlobalCreate; const reportOrDraftReport = getReportOrDraftReport(reportIDFromRoute); - const handleGoBackWithReportID = () => { + const handleGoBack = () => { if (isEditing) { Navigation.dismissModal(); } else { @@ -88,7 +88,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { changeTransactionsReport([transaction.transactionID], item.value); } - handleGoBackWithReportID(); + handleGoBack(); }; const selectReport = (item: TransactionGroupListItem) => { @@ -100,7 +100,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { // Early return for same report selection if (isSameReport) { - handleGoBackWithReportID(); + handleGoBack(); return; }