From 805d38c5cb1b9f0effbe3ac7cd14287bafcbca76 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 30 Jan 2025 23:28:27 +0700 Subject: [PATCH 1/8] feat: skip participant step in the create flow --- src/ROUTES.ts | 2 +- .../MoneyRequestConfirmationList.tsx | 5 +++ .../iou/request/step/IOURequestStepAmount.tsx | 15 ++++++-- .../request/step/IOURequestStepDistance.tsx | 38 ++++++++++++------- .../step/IOURequestStepScan/index.native.tsx | 22 ++++++++--- .../request/step/IOURequestStepScan/index.tsx | 15 ++++++-- 6 files changed, 70 insertions(+), 27 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index d08669c2693d6..143ff3c2d7de2 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -684,7 +684,7 @@ const ROUTES = { }, MONEY_REQUEST_STEP_PARTICIPANTS: { route: ':action/:iouType/participants/:transactionID/:reportID', - getRoute: (iouType: IOUType, transactionID: string, reportID: string, backTo = '', action: IOUAction = 'create') => + getRoute: (iouType: IOUType, transactionID: string | undefined, reportID: string, backTo = '', action: IOUAction = 'create') => getUrlWithBackToParam(`${action as string}/${iouType as string}/participants/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_SPLIT_PAYER: { diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 4536b18217a2c..6494ca54974bb 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -805,6 +805,11 @@ function MoneyRequestConfirmationList({ const navigateToReportOrUserDetail = (option: MoneyRequestConfirmationListItem) => { const activeRoute = Navigation.getActiveRoute(); + if (transaction?.isFromGlobalCreate) { + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + return; + } + if (option.isSelfDM) { Navigation.navigate(ROUTES.PROFILE.getRoute(currentUserPersonalDetails.accountID, activeRoute), CONST.NAVIGATION.ACTION_TYPE.PUSH); return; diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 32a75380f88a0..6d49da0262165 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -10,7 +10,8 @@ import {createDraftTransaction, removeDraftTransaction} from '@libs/actions/Tran import {convertToBackendAmount, isValidCurrencyCode} from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils'; -import {getBankAccountRoute, getTransactionDetails, isArchivedReport, isPolicyExpenseChat} from '@libs/ReportUtils'; +import {isPaidGroupPolicy} from '@libs/PolicyUtils'; +import {getBankAccountRoute, getPolicyExpenseChat, getTransactionDetails, isArchivedReport, isPolicyExpenseChat} from '@libs/ReportUtils'; import playSound, {SOUNDS} from '@libs/Sound'; import {calculateTaxAmount, getAmount, getCurrency, getDefaultTaxCode, getRequestType, getTaxValue} from '@libs/TransactionUtils'; import MoneyRequestAmountForm from '@pages/iou/MoneyRequestAmountForm'; @@ -75,6 +76,8 @@ function IOURequestStepAmount({ const [draftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`); const [splitDraftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`); const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`); + const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); + const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`); const isEditing = action === CONST.IOU.ACTION.EDIT; const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; @@ -180,7 +183,7 @@ function IOURequestStepAmount({ // In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. // If the user is started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. - if (report?.reportID && !isArchivedReport(reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { + if (report?.reportID && !isArchivedReport(reportNameValuePairs)) { const selectedParticipants = setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; @@ -245,7 +248,13 @@ function IOURequestStepAmount({ // If there was no reportID, then that means the user started this flow from the global + menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense. - navigateToParticipantPage(); + if (isPaidGroupPolicy(activePolicy)) { + const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); + setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); + navigateToConfirmationPage(); + } else { + navigateToParticipantPage(); + } }; const saveAmountAndCurrency = ({amount, paymentMethod}: AmountParams) => { diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 8c63012fb1861..5ca556b53f538 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -42,8 +42,8 @@ import {getLatestErrorField} from '@libs/ErrorUtils'; import {shouldUseTransactionDraft} from '@libs/IOUUtils'; import Navigation from '@libs/Navigation/Navigation'; import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils'; -import {getPersonalPolicy, getPolicy} from '@libs/PolicyUtils'; -import {isArchivedReport, isPolicyExpenseChat as isPolicyExpenseChatUtil} from '@libs/ReportUtils'; +import {getPersonalPolicy, getPolicy, isPaidGroupPolicy} from '@libs/PolicyUtils'; +import {getPolicyExpenseChat, isArchivedReport, isPolicyExpenseChat as isPolicyExpenseChatUtil} from '@libs/ReportUtils'; import playSound, {SOUNDS} from '@libs/Sound'; import {getDistanceInMeters, getRateID, getRequestType, getValidWaypoints, isCustomUnitRateIDForP2P} from '@libs/TransactionUtils'; import CONST from '@src/CONST'; @@ -81,6 +81,8 @@ function IOURequestStepDistance({ const [transactionBackup] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`); const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); + const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); + const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`); const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`); const [optimisticWaypoints, setOptimisticWaypoints] = useState(null); const waypoints = useMemo( @@ -307,7 +309,7 @@ function IOURequestStepDistance({ // In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. // If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. - if (report?.reportID && !isArchivedReport(reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { + if (report?.reportID && !isArchivedReport(reportNameValuePairs)) { const selectedParticipants = setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; @@ -380,24 +382,32 @@ function IOURequestStepDistance({ // If there was no reportID, then that means the user started this flow from the global menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense. - navigateToParticipantPage(); + if (isPaidGroupPolicy(activePolicy)) { + const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); + setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); + navigateToConfirmationPage(); + } else { + navigateToParticipantPage(); + } }, [ + transaction, + backTo, report, - iouType, + reportNameValuePairs, + activePolicy, transactionID, - backTo, - waypoints, - currentUserPersonalDetails, - personalDetails, + setDistanceRequestData, shouldSkipConfirmation, - transaction, - translate, - navigateToParticipantPage, navigateToConfirmationPage, + personalDetails, + translate, + iouType, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, policy, - reportNameValuePairs, + waypoints, customUnitRateID, - setDistanceRequestData, + navigateToParticipantPage, ]); const getError = () => { diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index ec32b709ad8f5..3d44e172f65bf 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -37,7 +37,8 @@ import {shouldStartLocationPermissionFlow} from '@libs/IOUUtils'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils'; -import {isArchivedReport, isPolicyExpenseChat} from '@libs/ReportUtils'; +import {isPaidGroupPolicy} from '@libs/PolicyUtils'; +import {getPolicyExpenseChat, isArchivedReport, isPolicyExpenseChat} from '@libs/ReportUtils'; import playSound, {SOUNDS} from '@libs/Sound'; import {getDefaultTaxCode} from '@libs/TransactionUtils'; import StepScreenWrapper from '@pages/iou/request/step/StepScreenWrapper'; @@ -86,6 +87,8 @@ function IOURequestStepScan({ const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`); + const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); + const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`); const platform = getPlatform(true); const [mutedPlatforms = {}] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS); const isPlatformMuted = mutedPlatforms[platform]; @@ -295,8 +298,14 @@ function IOURequestStepScan({ // If the transaction was created from the global create, the person needs to select participants, so take them there. // If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if ((transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) || iouType === CONST.IOU.TYPE.CREATE) { - navigateToParticipantPage(); + if (transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) { + if (isPaidGroupPolicy(activePolicy)) { + const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); + setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); + navigateToConfirmationPage(); + } else { + navigateToParticipantPage(); + } return; } @@ -413,19 +422,20 @@ function IOURequestStepScan({ [ backTo, transaction?.isFromGlobalCreate, - transaction?.attendees, transaction?.currency, transaction?.created, + transaction?.attendees, iouType, report, transactionID, shouldSkipConfirmation, navigateToConfirmationPage, + activePolicy, + currentUserPersonalDetails.accountID, + currentUserPersonalDetails.login, navigateToParticipantPage, personalDetails, createTransaction, - currentUserPersonalDetails.login, - currentUserPersonalDetails.accountID, reportID, transactionTaxCode, transactionTaxAmount, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index e31b13a4091e2..bcd332eb20f6b 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -35,7 +35,8 @@ import {shouldStartLocationPermissionFlow} from '@libs/IOUUtils'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils'; -import {isArchivedReport, isPolicyExpenseChat} from '@libs/ReportUtils'; +import {isPaidGroupPolicy} from '@libs/PolicyUtils'; +import {getPolicyExpenseChat, isArchivedReport, isPolicyExpenseChat} from '@libs/ReportUtils'; import playSound, {SOUNDS} from '@libs/Sound'; import {getDefaultTaxCode} from '@libs/TransactionUtils'; import ReceiptDropUI from '@pages/iou/ReceiptDropUI'; @@ -98,6 +99,8 @@ function IOURequestStepScan({ const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`); + const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); + const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`); const [isLoadingReceipt, setIsLoadingReceipt] = useState(false); const [videoConstraints, setVideoConstraints] = useState(); @@ -321,8 +324,14 @@ function IOURequestStepScan({ // If the transaction was created from the global create, the person needs to select participants, so take them there. // If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if ((transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) || iouType === CONST.IOU.TYPE.CREATE) { - navigateToParticipantPage(); + if (transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) { + if (isPaidGroupPolicy(activePolicy)) { + const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); + setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); + navigateToConfirmationPage(); + } else { + navigateToParticipantPage(); + } return; } From 4473b2d7e67aaf5d81afe67b2b432649e9855575 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 30 Jan 2025 23:42:04 +0700 Subject: [PATCH 2/8] fix lint --- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index bcd332eb20f6b..4c7369dc2a76b 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -448,23 +448,24 @@ function IOURequestStepScan({ [ backTo, transaction?.isFromGlobalCreate, - transaction?.attendees, transaction?.currency, transaction?.created, + transaction?.attendees, iouType, report, transactionID, shouldSkipConfirmation, navigateToConfirmationPage, + activePolicy, + currentUserPersonalDetails.accountID, + currentUserPersonalDetails.login, navigateToParticipantPage, personalDetails, - currentUserPersonalDetails.login, - currentUserPersonalDetails.accountID, + createTransaction, reportID, transactionTaxCode, transactionTaxAmount, policy, - createTransaction, ], ); From 9cefca8e09e0fc2f9ed66cc8708ee9e20f770c95 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 3 Feb 2025 11:48:10 +0700 Subject: [PATCH 3/8] add right icon --- src/ROUTES.ts | 2 +- src/components/MoneyRequestConfirmationList.tsx | 3 ++- src/components/SelectionList/BaseListItem.tsx | 3 ++- src/components/SelectionList/UserListItem.tsx | 9 +++++++++ src/components/SelectionList/types.ts | 3 +++ src/hooks/useHover.ts | 1 + src/pages/iou/request/step/IOURequestStepAmount.tsx | 9 ++++++++- src/pages/iou/request/step/IOURequestStepDistance.tsx | 9 ++++++++- .../iou/request/step/IOURequestStepScan/index.native.tsx | 9 ++++++++- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 9 ++++++++- 10 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index f4abbafbffa78..c67c821107998 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -506,7 +506,7 @@ const ROUTES = { }, MONEY_REQUEST_STEP_CONFIRMATION: { route: ':action/:iouType/confirmation/:transactionID/:reportID', - getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, participantsAutoAssigned?: boolean) => + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string | undefined, participantsAutoAssigned?: boolean) => `${action as string}/${iouType as string}/confirmation/${transactionID}/${reportID}${participantsAutoAssigned ? '?participantsAutoAssigned=true' : ''}` as const, }, MONEY_REQUEST_STEP_AMOUNT: { diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 6494ca54974bb..d09d4a2bbfa08 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -719,6 +719,7 @@ function MoneyRequestConfirmationList({ ...participant, isSelected: false, isInteractive: !shouldDisableParticipant(participant), + shouldShowRightIcon: transaction?.isFromGlobalCreate, })); options.push({ title: translate('common.to'), @@ -728,7 +729,7 @@ function MoneyRequestConfirmationList({ } return options; - }, [isTypeSplit, translate, payeePersonalDetails, getSplitSectionHeader, splitParticipants, selectedParticipants]); + }, [isTypeSplit, translate, payeePersonalDetails, getSplitSectionHeader, splitParticipants, selectedParticipants, transaction?.isFromGlobalCreate]); useEffect(() => { if (!isDistanceRequest || (isMovingTransactionFromTrackExpense && !isPolicyExpenseChat) || !transactionID) { diff --git a/src/components/SelectionList/BaseListItem.tsx b/src/components/SelectionList/BaseListItem.tsx index 57fd457b4b009..35c79f685830a 100644 --- a/src/components/SelectionList/BaseListItem.tsx +++ b/src/components/SelectionList/BaseListItem.tsx @@ -40,7 +40,7 @@ function BaseListItem({ const theme = useTheme(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const {hovered, bind} = useHover(); + const {hovered, bind, setHovered} = useHover(); const {isMouseDownOnInput, setMouseUp} = useMouseContext(); const pressableRef = useRef(null); @@ -50,6 +50,7 @@ function BaseListItem({ const handleMouseLeave = (e: React.MouseEvent) => { e.stopPropagation(); setMouseUp(); + setHovered(false); }; const rightHandSideComponentRender = () => { diff --git a/src/components/SelectionList/UserListItem.tsx b/src/components/SelectionList/UserListItem.tsx index a98e2a5f67261..a0fa27a5cc433 100644 --- a/src/components/SelectionList/UserListItem.tsx +++ b/src/components/SelectionList/UserListItem.tsx @@ -13,6 +13,7 @@ import useLocalize from '@hooks/useLocalize'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import getButtonState from '@libs/getButtonState'; import CONST from '@src/CONST'; import type {Icon as IconType} from '@src/types/onyx/OnyxCommon'; import BaseListItem from './BaseListItem'; @@ -147,6 +148,14 @@ function UserListItem({ )} {!!item.rightElement && item.rightElement} + {!!item.shouldShowRightIcon && ( + + + + )} )} diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index 9f39de02f334c..6d7ffccea17aa 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -200,6 +200,9 @@ type ListItem = { /** The style to override the default appearance */ itemStyle?: StyleProp; + + /** Boolean whether to display the right icon */ + shouldShowRightIcon?: boolean; }; type TransactionListItemType = ListItem & diff --git a/src/hooks/useHover.ts b/src/hooks/useHover.ts index 3e65979f6740c..fb2406c4a1c84 100644 --- a/src/hooks/useHover.ts +++ b/src/hooks/useHover.ts @@ -8,6 +8,7 @@ const useHover = () => { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), }, + setHovered, }; }; diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 6d49da0262165..bba57f9379e01 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -251,7 +251,14 @@ function IOURequestStepAmount({ if (isPaidGroupPolicy(activePolicy)) { const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); - navigateToConfirmationPage(); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute( + CONST.IOU.ACTION.CREATE, + iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType, + transactionID, + activePolicyExpenseChat?.reportID, + ), + ); } else { navigateToParticipantPage(); } diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 5ca556b53f538..b048c23ad278b 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -385,7 +385,14 @@ function IOURequestStepDistance({ if (isPaidGroupPolicy(activePolicy)) { const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); - navigateToConfirmationPage(); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute( + CONST.IOU.ACTION.CREATE, + iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType, + transactionID, + activePolicyExpenseChat?.reportID, + ), + ); } else { navigateToParticipantPage(); } diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 3d44e172f65bf..4767eeb87650e 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -302,7 +302,14 @@ function IOURequestStepScan({ if (isPaidGroupPolicy(activePolicy)) { const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); - navigateToConfirmationPage(); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute( + CONST.IOU.ACTION.CREATE, + iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType, + transactionID, + activePolicyExpenseChat?.reportID, + ), + ); } else { navigateToParticipantPage(); } diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 4c7369dc2a76b..8075b24bea4b1 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -328,7 +328,14 @@ function IOURequestStepScan({ if (isPaidGroupPolicy(activePolicy)) { const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); - navigateToConfirmationPage(); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute( + CONST.IOU.ACTION.CREATE, + iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType, + transactionID, + activePolicyExpenseChat?.reportID, + ), + ); } else { navigateToParticipantPage(); } From e8362fea24eb3fec61f5e7f4f9ee33ca96a6141c Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 3 Feb 2025 11:52:05 +0700 Subject: [PATCH 4/8] remove unnecessary condition --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index bba57f9379e01..6d2634484d2aa 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -183,7 +183,7 @@ function IOURequestStepAmount({ // In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. // If the user is started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. - if (report?.reportID && !isArchivedReport(reportNameValuePairs)) { + if (report?.reportID && !isArchivedReport(reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { const selectedParticipants = setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index b048c23ad278b..958553437b7db 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -309,7 +309,7 @@ function IOURequestStepDistance({ // In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. // If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. - if (report?.reportID && !isArchivedReport(reportNameValuePairs)) { + if (report?.reportID && !isArchivedReport(reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { const selectedParticipants = setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; From 75a3fa5c1bb699a715cb58d813b5ac26fa68f22c Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 4 Feb 2025 10:42:49 +0700 Subject: [PATCH 5/8] remove unchange --- src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 2 +- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 4767eeb87650e..94f5f659ffd47 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -298,7 +298,7 @@ function IOURequestStepScan({ // If the transaction was created from the global create, the person needs to select participants, so take them there. // If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) { + if ((transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) || iouType === CONST.IOU.TYPE.CREATE) { if (isPaidGroupPolicy(activePolicy)) { const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 8075b24bea4b1..bdedcb1c36928 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -324,7 +324,7 @@ function IOURequestStepScan({ // If the transaction was created from the global create, the person needs to select participants, so take them there. // If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) { + if ((transaction?.isFromGlobalCreate && iouType !== CONST.IOU.TYPE.TRACK && !report?.reportID) || iouType === CONST.IOU.TYPE.CREATE) { if (isPaidGroupPolicy(activePolicy)) { const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); From d99cf559089f2bd48795edaf26ac1e2db1c0277d Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 6 Feb 2025 16:50:28 +0700 Subject: [PATCH 6/8] fix navigate logic of To section --- .../MoneyRequestConfirmationList.tsx | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 44ce980e3e971..aeaf49faedbcc 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -718,7 +718,7 @@ function MoneyRequestConfirmationList({ const formattedSelectedParticipants = selectedParticipants.map((participant) => ({ ...participant, isSelected: false, - isInteractive: !shouldDisableParticipant(participant), + isInteractive: transaction?.isFromGlobalCreate, shouldShowRightIcon: transaction?.isFromGlobalCreate, })); options.push({ @@ -801,26 +801,14 @@ function MoneyRequestConfirmationList({ }, [transactionID, policyTagLists, policyTags]); /** - * Navigate to report details or profile of selected user + * Navigate to the participant step */ - const navigateToReportOrUserDetail = (option: MoneyRequestConfirmationListItem) => { - const activeRoute = Navigation.getActiveRoute(); - - if (transaction?.isFromGlobalCreate) { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); + const navigateToParticipantPage = () => { + if (!transaction?.isFromGlobalCreate) { return; } - if (option.isSelfDM) { - Navigation.navigate(ROUTES.PROFILE.getRoute(currentUserPersonalDetails.accountID, activeRoute), CONST.NAVIGATION.ACTION_TYPE.PUSH); - return; - } - - if (option.accountID) { - Navigation.navigate(ROUTES.PROFILE.getRoute(option.accountID, activeRoute), CONST.NAVIGATION.ACTION_TYPE.PUSH); - } else if (option.reportID) { - Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(option.reportID, activeRoute), CONST.NAVIGATION.ACTION_TYPE.PUSH); - } + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); }; /** @@ -1047,7 +1035,7 @@ function MoneyRequestConfirmationList({ sections={sections} ListItem={UserListItem} - onSelectRow={navigateToReportOrUserDetail} + onSelectRow={navigateToParticipantPage} shouldSingleExecuteRowSelect canSelectMultiple={false} shouldPreventDefaultFocusOnSelectRow From 52b5cdb15e14bbd029c215f3ae11c9a41e8ad5ff Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 7 Feb 2025 14:22:34 +0700 Subject: [PATCH 7/8] remove setHover --- src/components/SelectionList/BaseListItem.tsx | 3 +-- src/hooks/useHover.ts | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/SelectionList/BaseListItem.tsx b/src/components/SelectionList/BaseListItem.tsx index a0416fcb7bf2e..0bcf8cd978c5c 100644 --- a/src/components/SelectionList/BaseListItem.tsx +++ b/src/components/SelectionList/BaseListItem.tsx @@ -40,7 +40,7 @@ function BaseListItem({ const theme = useTheme(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const {hovered, bind, setHovered} = useHover(); + const {hovered, bind} = useHover(); const {isMouseDownOnInput, setMouseUp} = useMouseContext(); const pressableRef = useRef(null); @@ -51,7 +51,6 @@ function BaseListItem({ bind.onMouseLeave(); e.stopPropagation(); setMouseUp(); - setHovered(false); }; const rightHandSideComponentRender = () => { diff --git a/src/hooks/useHover.ts b/src/hooks/useHover.ts index fb2406c4a1c84..3e65979f6740c 100644 --- a/src/hooks/useHover.ts +++ b/src/hooks/useHover.ts @@ -8,7 +8,6 @@ const useHover = () => { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), }, - setHovered, }; }; From 43cab68fc19e983678011b32fe23287dc664c853 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 7 Feb 2025 14:26:17 +0700 Subject: [PATCH 8/8] prevent auto assign for send invoice --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 47f68176f8fa0..7c2d6d1804e0a 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -251,7 +251,7 @@ function IOURequestStepAmount({ // If there was no reportID, then that means the user started this flow from the global + menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense. - if (isPaidGroupPolicy(activePolicy)) { + if (iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(activePolicy) && activePolicy?.isPolicyExpenseChatEnabled) { const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); Navigation.navigate( diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index e9f1d16497462..f83b4f6a60820 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -376,7 +376,7 @@ function IOURequestStepDistance({ // If there was no reportID, then that means the user started this flow from the global menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense. - if (isPaidGroupPolicy(activePolicy)) { + if (iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(activePolicy) && activePolicy?.isPolicyExpenseChatEnabled) { const activePolicyExpenseChat = getPolicyExpenseChat(currentUserPersonalDetails.accountID, activePolicy?.id); setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat); Navigation.navigate(