From 8300b62fda57b51c43d96d96408c88b13e479cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kali=C5=84ski?= Date: Wed, 16 Jul 2025 12:43:09 +0200 Subject: [PATCH 01/42] Show report total and report status in the new report preview component --- .../MoneyRequestReportPreviewContent.tsx | 103 +++++++++++++----- src/languages/en.ts | 1 + src/languages/es.ts | 1 + 3 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 95d9a3c65c43..ed31eebd5d0b 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -72,6 +72,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {Transaction} from '@src/types/onyx'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; +import { convertToDisplayString } from '@libs/CurrencyUtils'; import EmptyMoneyRequestReportPreview from './EmptyMoneyRequestReportPreview'; import type {MoneyRequestReportPreviewContentProps} from './types'; @@ -293,19 +294,53 @@ function MoneyRequestReportPreviewContent({ * There is an edge case when there is only one distance expense with a pending route and amount = 0. In this case, we don't want to show the merchant or description because it says: "Pending route...", which is already displayed in the amount field. */ - const {supportText} = useMemo(() => { - if (numberOfRequests === 1) { - return { - supportText: '', - }; - } + const {expenseCountText} = useMemo(() => { return { - supportText: translate('iou.expenseCount', { + expenseCountText: translate('iou.expenseCount', { count: numberOfRequests, }), }; }, [translate, numberOfRequests]); + const isReportDeleted = action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; + + // Nedded for the status in the subheader of the report preview + // ====================================== + // State | Status | What to display? | + // 0 | 0 | Draft | + // 1 | 1 | Outstanding | + // 2 | 2 | Done | + // 2 | 3 | Approved | + // 2 | 4 | Paid | + // 3 | 4 | Paid | + // 6 | 4 | Paid | + // ====================================== + const {getReportStatus} = useMemo(() => { + if (iouReport?.stateNum === CONST.REPORT.STATE_NUM.OPEN && iouReport?.statusNum === CONST.REPORT.STATUS_NUM.OPEN) { + return { + getReportStatus: translate('common.draft'), + }; + } + if (iouReport?.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && iouReport?.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED) { + return { + getReportStatus: translate('common.outstanding'), + }; + } + if (iouReport?.stateNum === CONST.REPORT.STATE_NUM.APPROVED && iouReport?.statusNum === CONST.REPORT.STATUS_NUM.CLOSED) { + return { + getReportStatus: translate('common.done'), + }; + } + if (iouReport?.stateNum === CONST.REPORT.STATE_NUM.APPROVED && iouReport?.statusNum === CONST.REPORT.STATUS_NUM.APPROVED) { + return { + getReportStatus: translate('iou.approved'), + }; + } + return { + getReportStatus: translate('iou.settledExpensify'), + }; + }, [translate, iouReport]); + useEffect(() => { if (!isPaidAnimationRunning || isApprovedAnimationRunning) { return; @@ -492,8 +527,6 @@ function MoneyRequestReportPreviewContent({ [chatReportID, iouReport?.parentReportID, iouReport?.reportID, policy, translate], ); - const isReportDeleted = action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; - const reportPreviewActions = { [CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT]: (