From 99f754410e0028339ec09478d7c731236e145f6e Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Sun, 30 Jun 2024 04:28:36 +0530 Subject: [PATCH 01/17] fix: Search - RHP closes or returns to transaction thread depending on which field is edited. Signed-off-by: Krishna Gupta --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 11 +++-------- src/pages/iou/request/step/IOURequestStepDistance.tsx | 9 +++++---- .../request/step/IOURequestStepScan/index.native.tsx | 2 +- .../iou/request/step/IOURequestStepScan/index.tsx | 4 ++-- src/pages/iou/request/step/IOURequestStepTag.tsx | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 04c8e772844b..3f2c2a938e21 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -280,12 +280,7 @@ function IOURequestStepAmount({ // If the value hasn't changed, don't request to save changes on the server and just close the modal const transactionCurrency = TransactionUtils.getCurrency(currentTransaction); if (newAmount === TransactionUtils.getAmount(currentTransaction) && currency === transactionCurrency) { - if (isSplitBill) { - Navigation.goBack(backTo); - } else { - Navigation.dismissModal(); - } - + navigateBack(); return; } @@ -298,12 +293,12 @@ function IOURequestStepAmount({ if (isSplitBill) { IOU.setDraftSplitTransaction(transactionID, {amount: newAmount, currency, taxCode, taxAmount}); - Navigation.goBack(backTo); + navigateBack(); return; } IOU.updateMoneyRequestAmountAndCurrency({transactionID, transactionThreadReportID: reportID, currency, amount: newAmount, taxAmount, policy, taxCode}); - Navigation.dismissModal(); + navigateBack(); }; return ( diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 11d5687a55e9..2735a2f90411 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -171,9 +171,9 @@ function IOURequestStepDistance({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const navigateBack = () => { + const navigateBack = useCallback(() => { Navigation.goBack(backTo); - }; + }, [backTo]); /** * Takes the user to the page for editing a specific waypoint @@ -379,7 +379,7 @@ function IOURequestStepDistance({ const addresses = Object.fromEntries(Object.entries(waypoints).map(([key, waypoint]) => [key, 'address' in waypoint ? waypoint.address : {}])); const hasRouteChanged = !isEqual(transactionBackup?.routes, transaction?.routes); if (isEqual(oldAddresses, addresses)) { - Navigation.dismissModal(); + navigateBack(); return; } IOU.updateMoneyRequestDistance({ @@ -389,12 +389,13 @@ function IOURequestStepDistance({ ...(hasRouteChanged ? {routes: transaction?.routes} : {}), policy, }); - Navigation.dismissModal(); + navigateBack(); return; } navigateToNextStep(); }, [ + navigateBack, duplicateWaypointsError, atLeastTwoDifferentWaypointsError, hasRouteError, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 056a03b3b8f5..b5220ee53e15 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -370,7 +370,7 @@ function IOURequestStepScan({ const updateScanAndNavigate = useCallback( (file: FileObject, source: string) => { - Navigation.dismissModal(); + navigateBack(); IOU.replaceReceipt(transactionID, file as File, source); }, [transactionID], diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 00e0e14ee27c..8b0e17f7e6ef 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -417,9 +417,9 @@ function IOURequestStepScan({ const updateScanAndNavigate = useCallback( (file: FileObject, source: string) => { IOU.replaceReceipt(transactionID, file as File, source); - Navigation.dismissModal(); + navigateBack(); }, - [transactionID], + [transactionID, navigateBack], ); /** diff --git a/src/pages/iou/request/step/IOURequestStepTag.tsx b/src/pages/iou/request/step/IOURequestStepTag.tsx index d50b90f6d1ae..2d068e9acb81 100644 --- a/src/pages/iou/request/step/IOURequestStepTag.tsx +++ b/src/pages/iou/request/step/IOURequestStepTag.tsx @@ -98,7 +98,7 @@ function IOURequestStepTag({ } if (isEditing) { IOU.updateMoneyRequestTag(transactionID, report?.reportID ?? '-1', updatedTag, policy, policyTags, policyCategories); - Navigation.dismissModal(); + navigateBack(); return; } IOU.setMoneyRequestTag(transactionID, updatedTag); From c3344a465ac21c3bc88becc5ebc7f29ffc4e7cd3 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Sun, 30 Jun 2024 04:42:59 +0530 Subject: [PATCH 02/17] minor update. Signed-off-by: Krishna Gupta --- .../ReportActionItem/MoneyRequestView.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index a0d73a1b2844..29836183b8c9 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -12,6 +12,7 @@ import ReceiptEmptyState from '@components/ReceiptEmptyState'; import Switch from '@components/Switch'; import Text from '@components/Text'; import ViolationMessages from '@components/ViolationMessages'; +import useIsReportOpenInRHP from '@hooks/useIsReportOpenInRHP'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePermissions from '@hooks/usePermissions'; @@ -115,6 +116,7 @@ function MoneyRequestView({ const {isOffline} = useNetwork(); const {translate, toLocaleDigit} = useLocalize(); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); + const isReportOpenInRHP = useIsReportOpenInRHP(); const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '-1']; const isTrackExpense = ReportUtils.isTrackExpenseReport(report); @@ -216,17 +218,22 @@ function MoneyRequestView({ merchantTitle = translate('iou.receiptStatusTitle'); amountTitle = translate('iou.receiptStatusTitle'); } + const saveBillable = useCallback( (newBillable: boolean) => { // If the value hasn't changed, don't request to save changes on the server and just close the modal if (newBillable === TransactionUtils.getBillable(transaction)) { - Navigation.dismissModal(); + if (!isReportOpenInRHP) { + Navigation.dismissModal(); + } return; } IOU.updateMoneyRequestBillable(transaction?.transactionID ?? '-1', report?.reportID, newBillable, policy, policyTagList, policyCategories); - Navigation.dismissModal(); + if (!isReportOpenInRHP) { + Navigation.dismissModal(); + } }, - [transaction, report, policy, policyTagList, policyCategories], + [transaction, report, policy, policyTagList, policyCategories, isReportOpenInRHP], ); if (isCardTransaction) { From 632df80823af323216b79a7b63eb8b56151a6449 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Sun, 30 Jun 2024 05:55:09 +0530 Subject: [PATCH 03/17] fix lint warning. Signed-off-by: Krishna Gupta --- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 8b0e17f7e6ef..570a1cf3a294 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -230,9 +230,9 @@ function IOURequestStepScan({ }); } - const navigateBack = () => { + const navigateBack = useCallback(() => { Navigation.goBack(backTo); - }; + }, [backTo]); const navigateToParticipantPage = useCallback(() => { switch (iouType) { From 00d5b265b0c8538e0ece52d8b6eaf87654563919 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Wed, 3 Jul 2024 02:53:52 +0530 Subject: [PATCH 04/17] fix: Distance - Start and Stop labels do not change when dragging one over another. Signed-off-by: Krishna Gupta --- src/libs/actions/IOU.ts | 4 ++-- .../request/step/IOURequestStepDistance.tsx | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 48c70021cacc..831291cbd6e5 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -339,8 +339,8 @@ function initMoneyRequest(reportID: string, policy: OnyxEntry, // Add initial empty waypoints when starting a distance expense if (iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE) { comment.waypoints = { - waypoint0: {}, - waypoint1: {}, + waypoint0: {keyForList: 'start_waypoint'}, + waypoint1: {keyForList: 'stop_waypoint'}, }; if (!isFromGlobalCreate) { const customUnitRateID = DistanceRequestUtils.getCustomUnitRateID(reportID); diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 11d5687a55e9..acbec6ece047 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -76,7 +76,15 @@ function IOURequestStepDistance({ const {translate} = useLocalize(); const [optimisticWaypoints, setOptimisticWaypoints] = useState(null); - const waypoints = useMemo(() => optimisticWaypoints ?? transaction?.comment?.waypoints ?? {waypoint0: {}, waypoint1: {}}, [optimisticWaypoints, transaction]); + const waypoints = useMemo( + () => + optimisticWaypoints ?? + transaction?.comment?.waypoints ?? { + waypoint0: {keyForList: 'start_waypoint'}, + waypoint1: {keyForList: 'stop_waypoint'}, + }, + [optimisticWaypoints, transaction], + ); const waypointsList = Object.keys(waypoints); const previousWaypoints = usePrevious(waypoints); const numberOfWaypoints = Object.keys(waypoints).length; @@ -92,7 +100,14 @@ function IOURequestStepDistance({ const isRouteAbsentWithoutErrors = !hasRoute && !hasRouteError; const shouldFetchRoute = (isRouteAbsentWithoutErrors || haveValidatedWaypointsChanged) && !isLoadingRoute && Object.keys(validatedWaypoints).length > 1; const [shouldShowAtLeastTwoDifferentWaypointsError, setShouldShowAtLeastTwoDifferentWaypointsError] = useState(false); - const nonEmptyWaypointsCount = useMemo(() => Object.keys(waypoints).filter((key) => !isEmpty(waypoints[key])).length, [waypoints]); + const nonEmptyWaypointsCount = useMemo( + () => + Object.keys(waypoints).filter((key) => { + const {keyForList, ...waypointWithoutKey} = waypoints[key]; + return !isEmpty(waypointWithoutKey); + }).length, + [waypoints], + ); const duplicateWaypointsError = useMemo( () => nonEmptyWaypointsCount >= 2 && Object.keys(validatedWaypoints).length !== nonEmptyWaypointsCount, [nonEmptyWaypointsCount, validatedWaypoints], From 717e2ec21e34e4ed6fddb1349df0e0588e9d0bb2 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Wed, 3 Jul 2024 03:26:42 +0530 Subject: [PATCH 05/17] minor fix. Signed-off-by: Krishna Gupta --- src/pages/iou/request/step/IOURequestStepDistance.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index acbec6ece047..ac90b126fdc0 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -361,7 +361,9 @@ function IOURequestStepDistance({ data.forEach((waypoint, index) => { newWaypoints[`waypoint${index}`] = waypoints[waypoint] ?? {}; // Find waypoint that BECOMES empty after dragging - if (isEmpty(newWaypoints[`waypoint${index}`]) && !isEmpty(waypoints[`waypoint${index}`] ?? {})) { + const {keyForList, ...newWaypointsWithoutKey} = newWaypoints[`waypoint${index}`]; + const {keyForList: waypointKey, ...waypointWithoutKey} = waypoints[`waypoint${index}`]; + if (isEmpty(newWaypointsWithoutKey) && !isEmpty(waypointWithoutKey ?? {})) { emptyWaypointIndex = index; } }); From 4b9db5fd1293a5d0d4fa3b8cfbd0055f1fc392fa Mon Sep 17 00:00:00 2001 From: BrtqKr Date: Fri, 5 Jul 2024 14:35:40 +0200 Subject: [PATCH 06/17] add condition for old dot messages --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 7102c9878dca..78a1841e373b 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -403,6 +403,9 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(Localize.translateLocal('iou.heldExpense')); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { Clipboard.setString(Localize.translateLocal('iou.unheldExpense')); + } else if (ReportActionsUtils.isOldDotReportAction(reportAction)) { + const oldDotActionMessage = ReportActionsUtils.getMessageOfOldDotReportAction(reportAction); + Clipboard.setString(oldDotActionMessage); } else if (content) { setClipboardMessage( content.replace(/()(.*?)(<\/mention-user>)/gi, (match, openTag: string, innerContent: string, closeTag: string): string => { From ca879b8b7b7388d10eab8af6f5e59aee0124c0bb Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 9 Jul 2024 17:43:34 +0800 Subject: [PATCH 07/17] update the selection only if the prop is updated --- src/components/Composer/index.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/Composer/index.tsx b/src/components/Composer/index.tsx index a41f983434d8..9e8de034186d 100755 --- a/src/components/Composer/index.tsx +++ b/src/components/Composer/index.tsx @@ -116,12 +116,10 @@ function Composer( }, [shouldClear, onClear]); useEffect(() => { - setSelection((prevSelection) => { - if (!!prevSelection && selectionProp.start === prevSelection.start && selectionProp.end === prevSelection.end) { - return; - } - return selectionProp; - }); + if (!!selection && selectionProp.start === selection.start && selectionProp.end === selection.end) { + return; + } + setSelection(selectionProp); }, [selectionProp]); /** From 82fc0971a7837042d9418bb3b28c08c1c095d914 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 9 Jul 2024 17:25:44 +0530 Subject: [PATCH 08/17] minor update. Signed-off-by: krishna2323 --- src/pages/iou/request/step/IOURequestStepDistance.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index ba0abaf65e54..2a84ea5fc8c6 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -361,10 +361,12 @@ function IOURequestStepDistance({ data.forEach((waypoint, index) => { newWaypoints[`waypoint${index}`] = waypoints[waypoint] ?? {}; // Find waypoint that BECOMES empty after dragging - const {keyForList, ...newWaypointsWithoutKey} = newWaypoints[`waypoint${index}`]; - const {keyForList: waypointKey, ...waypointWithoutKey} = waypoints[`waypoint${index}`]; - if (isEmpty(newWaypointsWithoutKey) && !isEmpty(waypointWithoutKey ?? {})) { - emptyWaypointIndex = index; + if (newWaypoints[`waypoint${index}`] && waypoints[`waypoint${index}`]) { + const {keyForList, ...newWaypointsWithoutKey} = newWaypoints[`waypoint${index}`]; + const {keyForList: waypointKey, ...waypointWithoutKey} = waypoints[`waypoint${index}`]; + if (isEmpty(newWaypointsWithoutKey) && !isEmpty(waypointWithoutKey ?? {})) { + emptyWaypointIndex = index; + } } }); From 7e3dce3a5d89f32f7a15e623df68845a55806870 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 10 Jul 2024 11:45:48 +0800 Subject: [PATCH 09/17] suppress lint --- src/components/Composer/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Composer/index.tsx b/src/components/Composer/index.tsx index 9e8de034186d..3889c8597843 100755 --- a/src/components/Composer/index.tsx +++ b/src/components/Composer/index.tsx @@ -120,6 +120,7 @@ function Composer( return; } setSelection(selectionProp); + // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, [selectionProp]); /** From 08362b49b7597658ebe927d2af75759afa49e665 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 10 Jul 2024 20:59:58 +0530 Subject: [PATCH 10/17] remove Navigation.dismissModal() when toggling billable field. Signed-off-by: krishna2323 --- src/components/ReportActionItem/MoneyRequestView.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 29836183b8c9..d51c73aeec85 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -223,15 +223,9 @@ function MoneyRequestView({ (newBillable: boolean) => { // If the value hasn't changed, don't request to save changes on the server and just close the modal if (newBillable === TransactionUtils.getBillable(transaction)) { - if (!isReportOpenInRHP) { - Navigation.dismissModal(); - } return; } IOU.updateMoneyRequestBillable(transaction?.transactionID ?? '-1', report?.reportID, newBillable, policy, policyTagList, policyCategories); - if (!isReportOpenInRHP) { - Navigation.dismissModal(); - } }, [transaction, report, policy, policyTagList, policyCategories, isReportOpenInRHP], ); From 0004814c45a311dbb652eb06e410566511edafe9 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 10 Jul 2024 21:02:04 +0530 Subject: [PATCH 11/17] minor fix. Signed-off-by: krishna2323 --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index d51c73aeec85..9bbe1221d529 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -227,7 +227,7 @@ function MoneyRequestView({ } IOU.updateMoneyRequestBillable(transaction?.transactionID ?? '-1', report?.reportID, newBillable, policy, policyTagList, policyCategories); }, - [transaction, report, policy, policyTagList, policyCategories, isReportOpenInRHP], + [transaction, report, policy, policyTagList, policyCategories], ); if (isCardTransaction) { From 31c4a3d4be63d1e03a2092ae79db20b9ef0b33a4 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 11 Jul 2024 03:58:20 +0530 Subject: [PATCH 12/17] fix lint issue. Signed-off-by: krishna2323 --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 9bbe1221d529..618503e19c33 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -12,7 +12,6 @@ import ReceiptEmptyState from '@components/ReceiptEmptyState'; import Switch from '@components/Switch'; import Text from '@components/Text'; import ViolationMessages from '@components/ViolationMessages'; -import useIsReportOpenInRHP from '@hooks/useIsReportOpenInRHP'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePermissions from '@hooks/usePermissions'; @@ -116,7 +115,6 @@ function MoneyRequestView({ const {isOffline} = useNetwork(); const {translate, toLocaleDigit} = useLocalize(); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); - const isReportOpenInRHP = useIsReportOpenInRHP(); const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '-1']; const isTrackExpense = ReportUtils.isTrackExpenseReport(report); From b75e682bfa7274fae256afe4c6b72a118760d1c5 Mon Sep 17 00:00:00 2001 From: BrtqKr Date: Thu, 11 Jul 2024 11:42:30 +0200 Subject: [PATCH 13/17] add additional condition for the sidebar --- src/libs/OptionsListUtils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index f20d27ffdf22..31c4655aa5f3 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -716,6 +716,8 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(TaskUtils.getTaskReportActionMessage(lastReportAction).text); } else if (ReportActionUtils.isCreatedTaskReportAction(lastReportAction)) { lastMessageTextFromReport = TaskUtils.getTaskCreatedMessage(lastReportAction); + } else if (lastReportAction?.actionName && ReportActionUtils.isOldDotReportAction(lastReportAction)) { + lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction); } else if (ReportActionUtils.isApprovedOrSubmittedReportAction(lastReportAction)) { lastMessageTextFromReport = ReportActionUtils.getReportActionMessageText(lastReportAction); } From c686eb207d1b688e6c9684382feeb1afd4e13fc5 Mon Sep 17 00:00:00 2001 From: VH Date: Fri, 12 Jul 2024 05:54:02 +0700 Subject: [PATCH 14/17] Skip call OpenWorkspaceView on workspace profile page --- src/pages/workspace/WorkspaceProfilePage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index aa2683091f6f..96911233bbb2 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -148,7 +148,6 @@ function WorkspaceProfilePage({policyDraft, policy: policyProp, currencyList = { shouldShowOfflineIndicatorInWideScreen shouldShowNonAdmin icon={Illustrations.House} - shouldSkipVBBACall={false} > {(hasVBA?: boolean) => ( From e166e19aff08a5350d6cb68e9e440a2333a212a8 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Fri, 12 Jul 2024 06:59:26 +0530 Subject: [PATCH 15/17] added isWaypointEmpty to check if a waypoint is empty or not. Signed-off-by: krishna2323 --- .../request/step/IOURequestStepDistance.tsx | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 2a84ea5fc8c6..b5c48ffa3ded 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -32,7 +32,7 @@ import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type * as OnyxTypes from '@src/types/onyx'; import type {Errors} from '@src/types/onyx/OnyxCommon'; -import type {WaypointCollection} from '@src/types/onyx/Transaction'; +import type {Waypoint, WaypointCollection} from '@src/types/onyx/Transaction'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; import type {WithWritableReportOrNotFoundProps} from './withWritableReportOrNotFound'; @@ -100,14 +100,15 @@ function IOURequestStepDistance({ const isRouteAbsentWithoutErrors = !hasRoute && !hasRouteError; const shouldFetchRoute = (isRouteAbsentWithoutErrors || haveValidatedWaypointsChanged) && !isLoadingRoute && Object.keys(validatedWaypoints).length > 1; const [shouldShowAtLeastTwoDifferentWaypointsError, setShouldShowAtLeastTwoDifferentWaypointsError] = useState(false); - const nonEmptyWaypointsCount = useMemo( - () => - Object.keys(waypoints).filter((key) => { - const {keyForList, ...waypointWithoutKey} = waypoints[key]; - return !isEmpty(waypointWithoutKey); - }).length, - [waypoints], - ); + const isWaypointEmpty = (waypoint?: Waypoint) => { + if (!waypoint) { + return true; + } + const {keyForList, ...waypointWithoutKey} = waypoint; + return isEmpty(waypointWithoutKey); + }; + const nonEmptyWaypointsCount = useMemo(() => Object.keys(waypoints).filter((key) => !isWaypointEmpty(waypoints[key])).length, [waypoints]); + const duplicateWaypointsError = useMemo( () => nonEmptyWaypointsCount >= 2 && Object.keys(validatedWaypoints).length !== nonEmptyWaypointsCount, [nonEmptyWaypointsCount, validatedWaypoints], @@ -361,12 +362,8 @@ function IOURequestStepDistance({ data.forEach((waypoint, index) => { newWaypoints[`waypoint${index}`] = waypoints[waypoint] ?? {}; // Find waypoint that BECOMES empty after dragging - if (newWaypoints[`waypoint${index}`] && waypoints[`waypoint${index}`]) { - const {keyForList, ...newWaypointsWithoutKey} = newWaypoints[`waypoint${index}`]; - const {keyForList: waypointKey, ...waypointWithoutKey} = waypoints[`waypoint${index}`]; - if (isEmpty(newWaypointsWithoutKey) && !isEmpty(waypointWithoutKey ?? {})) { - emptyWaypointIndex = index; - } + if (!isWaypointEmpty(newWaypoints[`waypoint${index}`]) && !isWaypointEmpty(waypoints[`waypoint${index}`])) { + emptyWaypointIndex = index; } }); From 826e52f067cf0d411b6407be304a3b8af945ce44 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Fri, 12 Jul 2024 07:07:04 +0530 Subject: [PATCH 16/17] minor fix. Signed-off-by: krishna2323 --- src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index b5c48ffa3ded..f4dc08409824 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -362,7 +362,7 @@ function IOURequestStepDistance({ data.forEach((waypoint, index) => { newWaypoints[`waypoint${index}`] = waypoints[waypoint] ?? {}; // Find waypoint that BECOMES empty after dragging - if (!isWaypointEmpty(newWaypoints[`waypoint${index}`]) && !isWaypointEmpty(waypoints[`waypoint${index}`])) { + if (isWaypointEmpty(newWaypoints[`waypoint${index}`]) && !isWaypointEmpty(waypoints[`waypoint${index}`])) { emptyWaypointIndex = index; } }); From 73c33c72d3f6a2945c93d664d50499bd849b60e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Warcho=C5=82?= <61014013+war-in@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:18:08 +0200 Subject: [PATCH 17/17] Revert "Reset amount on reset button click" --- src/components/MoneyRequestAmountInput.tsx | 32 +++---------------- .../MoneyRequestConfirmationList.tsx | 6 +--- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/components/MoneyRequestAmountInput.tsx b/src/components/MoneyRequestAmountInput.tsx index 85bb79f85518..791b3e4d5e48 100644 --- a/src/components/MoneyRequestAmountInput.tsx +++ b/src/components/MoneyRequestAmountInput.tsx @@ -88,18 +88,6 @@ type MoneyRequestAmountInputProps = { * Autogrow input container length based on the entered text. */ autoGrow?: boolean; - - /** - * Determines whether the amount should be reset. - */ - shouldResetAmount?: boolean; - - /** - * Callback function triggered when the amount is reset. - * - * @param resetValue - A boolean indicating whether the amount should be reset. - */ - onResetAmount?: (resetValue: boolean) => void; }; type Selection = { @@ -135,8 +123,6 @@ function MoneyRequestAmountInput( hideFocusedState = true, shouldKeepUserInput = false, autoGrow = true, - shouldResetAmount, - onResetAmount, ...props }: MoneyRequestAmountInputProps, forwardedRef: ForwardedRef, @@ -216,21 +202,10 @@ function MoneyRequestAmountInput( })); useEffect(() => { - const frontendAmount = onFormatAmount(amount, currency); - setCurrentAmount(frontendAmount); - if (shouldResetAmount) { - setSelection({ - start: frontendAmount.length, - end: frontendAmount.length, - }); - onResetAmount?.(false); - return; - } - if ((!currency || typeof amount !== 'number' || (formatAmountOnBlur && isTextInputFocused(textInput))) ?? shouldKeepUserInput) { return; } - + const frontendAmount = onFormatAmount(amount, currency); setCurrentAmount(frontendAmount); // Only update selection if the amount prop was changed from the outside and is not the same as the current amount we just computed @@ -241,7 +216,10 @@ function MoneyRequestAmountInput( end: frontendAmount.length, }); } - }, [amount, currency, formatAmountOnBlur, shouldKeepUserInput, onFormatAmount, shouldResetAmount, onResetAmount, currentAmount]); + + // we want to re-initialize the state only when the amount changes + // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps + }, [amount, shouldKeepUserInput]); // Modifies the amount to match the decimals for changed currency. useEffect(() => { diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 98ed13a08363..772b1476b84a 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -300,7 +300,7 @@ function MoneyRequestConfirmationList({ const isMerchantRequired = isPolicyExpenseChat && (!isScanRequest || isEditingSplitBill) && shouldShowMerchant; const isCategoryRequired = !!policy?.requiresCategory; - const [shouldResetAmount, setShouldResetAmount] = useState(false); + useEffect(() => { if (shouldDisplayFieldError && didConfirmSplit) { setFormError('iou.error.genericSmartscanFailureMessage'); @@ -479,8 +479,6 @@ function MoneyRequestConfirmationList({ onFormatAmount={CurrencyUtils.convertToDisplayStringWithoutCurrency} onAmountChange={(value: string) => onSplitShareChange(participantOption.accountID ?? -1, Number(value))} maxLength={formattedTotalAmount.length} - shouldResetAmount={shouldResetAmount} - onResetAmount={(resetValue) => setShouldResetAmount(resetValue)} /> ), })); @@ -503,7 +501,6 @@ function MoneyRequestConfirmationList({ transaction?.comment?.splits, transaction?.splitShares, onSplitShareChange, - shouldResetAmount, ]); const isSplitModified = useMemo(() => { @@ -521,7 +518,6 @@ function MoneyRequestConfirmationList({ { IOU.resetSplitShares(transaction); - setShouldResetAmount(true); }} accessibilityLabel={CONST.ROLE.BUTTON} role={CONST.ROLE.BUTTON}