From e6c72f7ec518c64220cdfff1aa8cf01460a5e075 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 26 Sep 2024 12:55:14 +0200 Subject: [PATCH 1/3] uncomment invoicing lines --- src/libs/actions/Policy/Policy.ts | 7 +++---- src/pages/home/report/ReportActionItemMessage.tsx | 4 +--- .../workspace/invoices/WorkspaceInvoicingDetailsName.tsx | 3 +-- .../invoices/WorkspaceInvoicingDetailsWebsite.tsx | 3 +-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index db4fa4d417f6..e1d71232a268 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -3187,10 +3187,9 @@ function enablePolicyInvoicing(policyID: string, enabled: boolean) { API.write(WRITE_COMMANDS.ENABLE_POLICY_INVOICING, parameters, onyxData); - // TODO: Uncomment the following line when the invoices screen is ready - https://github.com/Expensify/App/issues/45175. - // if (enabled && getIsNarrowLayout()) { - // navigateWhenEnableFeature(policyID); - // } + if (enabled && getIsNarrowLayout()) { + navigateWhenEnableFeature(policyID); + } } function openPolicyMoreFeaturesPage(policyID: string) { diff --git a/src/pages/home/report/ReportActionItemMessage.tsx b/src/pages/home/report/ReportActionItemMessage.tsx index c0002d1a72e7..41b36fb3e2de 100644 --- a/src/pages/home/report/ReportActionItemMessage.tsx +++ b/src/pages/home/report/ReportActionItemMessage.tsx @@ -133,9 +133,7 @@ function ReportActionItemMessage({action, transaction, displayAsGroup, reportID, return; } - // TODO: Uncomment the following line when the invoices screen is ready - https://github.com/Expensify/App/issues/45175. - // Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID)) - Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)); + Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID)); }; return ( diff --git a/src/pages/workspace/invoices/WorkspaceInvoicingDetailsName.tsx b/src/pages/workspace/invoices/WorkspaceInvoicingDetailsName.tsx index fff7c592baaa..80f323431baa 100644 --- a/src/pages/workspace/invoices/WorkspaceInvoicingDetailsName.tsx +++ b/src/pages/workspace/invoices/WorkspaceInvoicingDetailsName.tsx @@ -42,8 +42,7 @@ function WorkspaceInvoicingDetailsName({route}: WorkspaceInvoicingDetailsNamePro Date: Wed, 2 Oct 2024 15:12:14 +0200 Subject: [PATCH 2/3] refactor ReportActionItemMessage for useOnyx --- .../home/report/ReportActionItemMessage.tsx | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/pages/home/report/ReportActionItemMessage.tsx b/src/pages/home/report/ReportActionItemMessage.tsx index 41b36fb3e2de..da2f3dd151c8 100644 --- a/src/pages/home/report/ReportActionItemMessage.tsx +++ b/src/pages/home/report/ReportActionItemMessage.tsx @@ -2,8 +2,7 @@ import type {ReactElement} from 'react'; import React from 'react'; import type {StyleProp, TextStyle, ViewStyle} from 'react-native'; import {View} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import Button from '@components/Button'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; @@ -14,16 +13,11 @@ import * as ReportUtils from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {ReportAction, Transaction} from '@src/types/onyx'; +import type {ReportAction} from '@src/types/onyx'; import TextCommentFragment from './comment/TextCommentFragment'; import ReportActionItemFragment from './ReportActionItemFragment'; -type ReportActionItemMessageOnyxProps = { - /** The transaction linked to the report action. */ - transaction: OnyxEntry; -}; - -type ReportActionItemMessageProps = ReportActionItemMessageOnyxProps & { +type ReportActionItemMessageProps = { /** The report action */ action: ReportAction; @@ -40,9 +34,10 @@ type ReportActionItemMessageProps = ReportActionItemMessageOnyxProps & { reportID: string; }; -function ReportActionItemMessage({action, transaction, displayAsGroup, reportID, style, isHidden = false}: ReportActionItemMessageProps) { +function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHidden = false}: ReportActionItemMessageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${ReportActionsUtils.getLinkedTransactionID(action) ?? -1}`); const fragments = ReportActionsUtils.getReportActionMessageFragments(action); const isIOUReport = ReportActionsUtils.isMoneyRequestAction(action); @@ -159,8 +154,4 @@ function ReportActionItemMessage({action, transaction, displayAsGroup, reportID, ReportActionItemMessage.displayName = 'ReportActionItemMessage'; -export default withOnyx({ - transaction: { - key: ({action}) => `${ONYXKEYS.COLLECTION.TRANSACTION}${ReportActionsUtils.getLinkedTransactionID(action) ?? -1}`, - }, -})(ReportActionItemMessage); +export default ReportActionItemMessage; From 8f22bff9bad8cf6af159c44678a64f867cd62a9d Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 3 Oct 2024 12:57:47 +0200 Subject: [PATCH 3/3] improve hasMissingInvoiceBankAccount --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 687ef177609e..c70e201b8dcc 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -8023,7 +8023,7 @@ function hasMissingInvoiceBankAccount(iouReportID: string): boolean { return false; } - return invoiceReport?.ownerAccountID === currentUserAccountID && isEmptyObject(getPolicy(invoiceReport?.policyID)?.invoice?.bankAccount ?? {}) && isSettled(iouReportID); + return invoiceReport?.ownerAccountID === currentUserAccountID && !getPolicy(invoiceReport?.policyID)?.invoice?.bankAccount?.transferBankAccountID && isSettled(iouReportID); } function isExpenseReportWithoutParentAccess(report: OnyxEntry) {