From 9a2baa0b3e8268dbef20155f117b814263a45146 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Mon, 6 May 2024 16:17:24 +0300 Subject: [PATCH] Revert "fix: show category picker when creating invoices" --- src/components/MoneyRequestConfirmationList.tsx | 6 ++---- src/libs/ReportUtils.ts | 1 - .../iou/request/step/IOURequestStepCategory.tsx | 16 +++++++--------- .../request/step/IOURequestStepConfirmation.tsx | 4 ++-- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 4e048def7ef3..4c5bb4d45318 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -294,12 +294,10 @@ function MoneyRequestConfirmationList({ const canUpdateSenderWorkspace = useMemo(() => PolicyUtils.canSendInvoice(allPolicies) && !!transaction?.isFromGlobalCreate, [allPolicies, transaction?.isFromGlobalCreate]); // A flag for showing the tags field - // TODO: remove the !isTypeInvoice from this condition after BE supports tags for invoices: https://github.com/Expensify/App/issues/41281 - const shouldShowTags = useMemo(() => isPolicyExpenseChat && OptionsListUtils.hasEnabledTags(policyTagLists) && !isTypeInvoice, [isPolicyExpenseChat, policyTagLists, isTypeInvoice]); + const shouldShowTags = useMemo(() => isPolicyExpenseChat && OptionsListUtils.hasEnabledTags(policyTagLists), [isPolicyExpenseChat, policyTagLists]); // A flag for showing tax rate - // TODO: remove the !isTypeInvoice from this condition after BE supports tax for invoices: https://github.com/Expensify/App/issues/41281 - const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy) && !isTypeInvoice; + const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy); // A flag for showing the billable field const shouldShowBillable = policy?.disabledFields?.defaultBillable === false; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f17b5f8b31e7..7da99d3ca8e6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6638,7 +6638,6 @@ export { isExpensifyOnlyParticipantInReport, isGroupChat, isGroupChatAdmin, - isGroupPolicy, isReportInGroupPolicy, isHoldCreator, isIOUOwnedByCurrentUser, diff --git a/src/pages/iou/request/step/IOURequestStepCategory.tsx b/src/pages/iou/request/step/IOURequestStepCategory.tsx index 4cbec02be858..4b34a6a19600 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.tsx +++ b/src/pages/iou/request/step/IOURequestStepCategory.tsx @@ -71,11 +71,9 @@ function IOURequestStepCategory({ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const reportAction = reportActions?.[report?.parentReportActionID || reportActionID] ?? null; - const shouldShowCategory = - (ReportUtils.isReportInGroupPolicy(report) || ReportUtils.isGroupPolicy(policy?.type ?? '')) && - // The transactionCategory can be an empty string, so to maintain the logic we'd like to keep it in this shape until utils refactor - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - (!!transactionCategory || OptionsListUtils.hasEnabledOptions(Object.values(policyCategories ?? {}))); + // The transactionCategory can be an empty string, so to maintain the logic we'd like to keep it in this shape until utils refactor + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const shouldShowCategory = ReportUtils.isReportInGroupPolicy(report) && (!!transactionCategory || OptionsListUtils.hasEnabledOptions(Object.values(policyCategories ?? {}))); const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; const canEditSplitBill = isSplitBill && reportAction && session?.accountID === reportAction.actorAccountID && TransactionUtils.areRequiredFieldsEmpty(transaction); @@ -142,7 +140,7 @@ function IOURequestStepCategory({ {translate('iou.categorySelection')} @@ -159,13 +157,13 @@ const IOURequestStepCategoryWithOnyx = withOnyx `${ONYXKEYS.COLLECTION.POLICY}${IOU.getIOURequestPolicyID(transaction, report)}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, }, policyCategories: { - key: ({report, transaction}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${IOU.getIOURequestPolicyID(transaction, report)}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report ? report.policyID : '0'}`, }, policyTags: { - key: ({report, transaction}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${IOU.getIOURequestPolicyID(transaction, report)}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, }, reportActions: { key: ({ diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 627db886366b..e33e4d8fb763 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -134,7 +134,7 @@ function IOURequestStepConfirmation({ }) ?? [], [transaction?.participants, personalDetails, iouType], ); - const isPolicyExpenseChat = useMemo(() => ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)) || ReportUtils.isGroupPolicy(policy?.type ?? ''), [report, policy]); + const isPolicyExpenseChat = useMemo(() => ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)), [report]); const formHasBeenSubmitted = useRef(false); useEffect(() => { @@ -563,7 +563,7 @@ function IOURequestStepConfirmation({ // split rather than forcing the user to create a new group, just for that expense. The reportID is empty, when the action was initiated from // the floating-action-button (since it is something that exists outside the context of a report). canModifyParticipants={!transaction?.isFromGlobalCreate} - policyID={report?.policyID ?? policy?.id ?? ''} + policyID={report?.policyID} bankAccountRoute={ReportUtils.getBankAccountRoute(report)} iouMerchant={transaction?.merchant} iouCreated={transaction?.created}