From 1830427970c5a1af630123dd90a47e6ba372b6d8 Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Tue, 7 May 2024 02:35:38 +0500 Subject: [PATCH 1/3] include an add workspace button when selecting participants --- src/libs/ReportUtils.ts | 42 ++++++++++--------- ...yForRefactorRequestParticipantsSelector.js | 26 ++++++++++-- .../step/IOURequestStepParticipants.tsx | 7 ++++ 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7e663b1c56ff..f1d1e4eae2b0 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6398,6 +6398,27 @@ function getReportActionActorAccountID(reportAction: OnyxEntry, io } } +function createDraftWorkspaceAndNavigateToConfirmationScreen(transactionID: string, actionName: IOUAction): void { + const isCategorizing = actionName === CONST.IOU.ACTION.CATEGORIZE; + const {expenseChatReportID, policyID, policyName} = PolicyActions.createDraftWorkspace(); + IOU.setMoneyRequestParticipants(transactionID, [ + { + selected: true, + accountID: 0, + isPolicyExpenseChat: true, + reportID: expenseChatReportID, + policyID, + searchText: policyName, + }, + ]); + const iouConfirmationPageRoute = ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(actionName, CONST.IOU.TYPE.SUBMIT, transactionID, expenseChatReportID); + if (isCategorizing) { + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(actionName, CONST.IOU.TYPE.SUBMIT, transactionID, expenseChatReportID, iouConfirmationPageRoute)); + } else { + Navigation.navigate(iouConfirmationPageRoute); + } +} + function createDraftTransactionAndNavigateToParticipantSelector(transactionID: string, reportID: string, actionName: IOUAction, reportActionID: string): void { const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? ({} as Transaction); const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? ([] as ReportAction[]); @@ -6433,25 +6454,7 @@ function createDraftTransactionAndNavigateToParticipantSelector(transactionID: s return; } - const {expenseChatReportID, policyID, policyName} = PolicyActions.createDraftWorkspace(); - const isCategorizing = actionName === CONST.IOU.ACTION.CATEGORIZE; - - IOU.setMoneyRequestParticipants(transactionID, [ - { - selected: true, - accountID: 0, - isPolicyExpenseChat: true, - reportID: expenseChatReportID, - policyID, - searchText: policyName, - }, - ]); - const iouConfirmationPageRoute = ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(actionName, CONST.IOU.TYPE.SUBMIT, transactionID, expenseChatReportID); - if (isCategorizing) { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(actionName, CONST.IOU.TYPE.SUBMIT, transactionID, expenseChatReportID, iouConfirmationPageRoute)); - } else { - Navigation.navigate(iouConfirmationPageRoute); - } + return createDraftWorkspaceAndNavigateToConfirmationScreen(transactionID, actionName); } /** @@ -6748,6 +6751,7 @@ export { shouldShowMerchantColumn, isCurrentUserInvoiceReceiver, isDraftReport, + createDraftWorkspaceAndNavigateToConfirmationScreen, }; export type { diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index ecf3c449b14b..6eead85959f2 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -299,7 +299,7 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({participants, onF return ( <> - {shouldShowReferralBanner && ( + {shouldShowReferralBanner && !isCategorizeOrShareAction && ( )} - {!!participants.length && ( + {!!participants.length && !isCategorizeOrShareAction && (