From 8777b897d631c9df8ebd5ab7cc98179bebe9480b Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 14 Nov 2024 13:34:11 +0100 Subject: [PATCH 1/7] render report fields for invoice in MoneyReportView --- src/components/ReportActionItem/MoneyReportView.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/ReportActionItem/MoneyReportView.tsx b/src/components/ReportActionItem/MoneyReportView.tsx index dfc88840446f..8bb87081347a 100644 --- a/src/components/ReportActionItem/MoneyReportView.tsx +++ b/src/components/ReportActionItem/MoneyReportView.tsx @@ -79,8 +79,10 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo const enabledReportFields = sortedPolicyReportFields.filter((reportField) => !ReportUtils.isReportFieldDisabled(report, reportField, policy)); const isOnlyTitleFieldEnabled = enabledReportFields.length === 1 && ReportUtils.isReportFieldOfTypeTitle(enabledReportFields.at(0)); - const shouldShowReportField = - !ReportUtils.isClosedExpenseReportWithNoExpenses(report) && ReportUtils.isPaidGroupPolicyExpenseReport(report) && (!isCombinedReport || !isOnlyTitleFieldEnabled); + const isClosedExpenseReportWithNoExpenses = ReportUtils.isClosedExpenseReportWithNoExpenses(report); + const isPaidGroupPolicyExpenseReport = ReportUtils.isPaidGroupPolicyExpenseReport(report); + const isInvoiceReport = ReportUtils.isInvoiceReport(report); + const shouldShowReportField = !isClosedExpenseReportWithNoExpenses && (isPaidGroupPolicyExpenseReport || isInvoiceReport) && (!isCombinedReport || !isOnlyTitleFieldEnabled); const renderThreadDivider = useMemo( () => @@ -102,9 +104,9 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo <> - {!ReportUtils.isClosedExpenseReportWithNoExpenses(report) && ( + {!isClosedExpenseReportWithNoExpenses && ( <> - {ReportUtils.isPaidGroupPolicyExpenseReport(report) && + {(isPaidGroupPolicyExpenseReport || isInvoiceReport) && policy?.areReportFieldsEnabled && (!isCombinedReport || !isOnlyTitleFieldEnabled) && sortedPolicyReportFields.map((reportField) => { From b699e4644fd98910b8c92486d0cf9a1d0aa0546d Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 14 Nov 2024 14:30:28 +0100 Subject: [PATCH 2/7] DEV: Ignore report errors --- src/libs/ReportUtils.ts | 8 ++++---- src/pages/home/ReportScreen.tsx | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 17ea13c694e8..3dd4acb27da5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6305,10 +6305,10 @@ function canAccessReport(report: OnyxEntry, policies: OnyxCollection= CONST.REPORT.MIN_INITIAL_REPORT_ACTION_COUNT || doesCreatedActionExists()); // If there's a non-404 error for the report we should show it instead of blocking the screen - const hasHelpfulErrors = Object.keys(report?.errorFields ?? {}).some((key) => key !== 'notFound'); + //! DEV + const hasHelpfulErrors = false; // Object.keys(report?.errorFields ?? {}).some((key) => key !== 'notFound'); const shouldHideReport = !hasHelpfulErrors && !ReportUtils.canAccessReport(report, policies, betas); const transactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(reportID ?? '', reportActions ?? [], isOffline); From 7ba97ac2f4c75c6d9bb21f155b98114372928417 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 5 Dec 2024 14:54:48 +0100 Subject: [PATCH 3/7] revert dev logs --- src/libs/ReportUtils.ts | 8 ++++---- src/pages/home/ReportScreen.tsx | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index dfe01e0c9258..136521e23f64 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6318,10 +6318,10 @@ function canAccessReport(report: OnyxEntry, policies: OnyxCollection= CONST.REPORT.MIN_INITIAL_REPORT_ACTION_COUNT || doesCreatedActionExists()); // If there's a non-404 error for the report we should show it instead of blocking the screen - //! DEV - const hasHelpfulErrors = false; // Object.keys(report?.errorFields ?? {}).some((key) => key !== 'notFound'); + const hasHelpfulErrors = Object.keys(report?.errorFields ?? {}).some((key) => key !== 'notFound'); const shouldHideReport = !hasHelpfulErrors && !ReportUtils.canAccessReport(report, policies, betas); const transactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(reportID ?? '', reportActions ?? [], isOffline); From 1954c1d18299f397d1f83f9f82e1dd5c7b9a84c9 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 5 Dec 2024 15:15:28 +0100 Subject: [PATCH 4/7] invert total calculation to include invoices in ReportListItem --- src/components/SelectionList/Search/ReportListItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index 18352c6e0596..e721fde89771 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -40,7 +40,7 @@ function TotalCell({showTooltip, isLargeScreenWidth, reportItem}: ReportCellProp // Only invert non-zero values otherwise we'll end up with -0.00 if (total) { - total *= reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1; + total *= reportItem?.type === CONST.REPORT.TYPE.EXPENSE || reportItem?.type === CONST.REPORT.TYPE.INVOICE ? -1 : 1; } return ( From ea8c1468c6e3f9348e24d80b19fa58499d24e876 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 6 Dec 2024 11:04:29 +0100 Subject: [PATCH 5/7] update reportFieldsEnabled logic to include invoice reports --- src/pages/EditReportFieldPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EditReportFieldPage.tsx b/src/pages/EditReportFieldPage.tsx index 6b25681fa8e8..1a082310ff53 100644 --- a/src/pages/EditReportFieldPage.tsx +++ b/src/pages/EditReportFieldPage.tsx @@ -40,7 +40,7 @@ function EditReportFieldPage({route}: EditReportFieldPageProps) { const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false); const {translate} = useLocalize(); const isReportFieldTitle = ReportUtils.isReportFieldOfTypeTitle(reportField); - const reportFieldsEnabled = (ReportUtils.isPaidGroupPolicyExpenseReport(report) && !!policy?.areReportFieldsEnabled) || isReportFieldTitle; + const reportFieldsEnabled = ((ReportUtils.isPaidGroupPolicyExpenseReport(report) || ReportUtils.isInvoiceReport(report)) && !!policy?.areReportFieldsEnabled) || isReportFieldTitle; if (!reportFieldsEnabled || !reportField || !policyField || !report || isDisabled) { return ( From 15eb5eda2ac29c0fe4ec68c802d81894bc54160f Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 6 Dec 2024 11:35:37 +0100 Subject: [PATCH 6/7] add support for displaying secondary avatar in invoice reports --- src/pages/home/report/ReportActionItemSingle.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index fa8230640c8e..37ea1c3eafcc 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -148,6 +148,17 @@ function ReportActionItemSingle({ const reportIcons = ReportUtils.getIcons(report, {}); secondaryAvatar = reportIcons.at(avatarIconIndex) ?? {name: '', source: '', type: CONST.ICON_TYPE_AVATAR}; + } else if (ReportUtils.isInvoiceReport(iouReport)) { + const secondaryAccountId = iouReport?.managerID ?? -1; + const secondaryUserAvatar = personalDetails?.[secondaryAccountId ?? -1]?.avatar ?? FallbackAvatar; + const secondaryDisplayName = ReportUtils.getDisplayNameForParticipant(secondaryAccountId); + + secondaryAvatar = { + source: secondaryUserAvatar, + type: CONST.ICON_TYPE_AVATAR, + name: secondaryDisplayName, + id: secondaryAccountId, + }; } else { secondaryAvatar = {name: '', source: '', type: 'avatar'}; } From fa8ec14c3ffd035beb6c854d2b9d0ed0c97c5e33 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 10 Dec 2024 16:59:42 +0100 Subject: [PATCH 7/7] handle case when invoice out of invoice room --- src/libs/ReportUtils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ba507ef681c7..ea9cbaa649dc 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4049,6 +4049,10 @@ function getReportName( } if (isInvoiceReport(report)) { + if (!isInvoiceRoom(getReport(report?.chatReportID ?? ''))) { + return report?.reportName ?? getMoneyRequestReportName(report, policy, invoiceReceiverPolicy); + } + formattedName = getMoneyRequestReportName(report, policy, invoiceReceiverPolicy); }