diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 73dfd37b9945..b3444dbf3582 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -26,8 +26,8 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useTransactionViolations from '@hooks/useTransactionViolations'; -import useViolations from '@hooks/useViolations'; import type {ViolationField} from '@hooks/useViolations'; +import useViolations from '@hooks/useViolations'; import {getCompanyCardDescription} from '@libs/CardUtils'; import {isCategoryMissing} from '@libs/CategoryUtils'; import {convertToDisplayString} from '@libs/CurrencyUtils'; @@ -38,6 +38,7 @@ import {hasEnabledOptions} from '@libs/OptionsListUtils'; import {getLengthOfTag, getTagLists, hasDependentTags as hasDependentTagsPolicyUtils, isTaxTrackingEnabled} from '@libs/PolicyUtils'; import {getOriginalMessage, isMoneyRequestAction} from '@libs/ReportActionsUtils'; import {isSplitAction} from '@libs/ReportSecondaryActionUtils'; +import type {TransactionDetails} from '@libs/ReportUtils'; import { canEditFieldOfMoneyRequest, canEditMoneyRequest, @@ -54,7 +55,6 @@ import { isTrackExpenseReport, shouldEnableNegative, } from '@libs/ReportUtils'; -import type {TransactionDetails} from '@libs/ReportUtils'; import {hasEnabledTags} from '@libs/TagsOptionsListUtils'; import { getBillable, @@ -437,6 +437,20 @@ function MoneyRequestView({ ], ); + const distanceCopyValue = !canEditDistance ? distanceToDisplay : undefined; + const distanceRateCopyValue = !canEditDistanceRate ? rateToDisplay : undefined; + const amountCopyValue = !canEditAmount ? amountTitle : undefined; + const descriptionCopyValue = !canEdit ? (updatedTransactionDescription ?? transactionDescription) : undefined; + const merchantCopyValue = !canEditMerchant ? updatedMerchantTitle : undefined; + const dateCopyValue = !canEditDate ? transactionDate : undefined; + const categoryValue = updatedTransaction?.category ?? categoryForDisplay; + const categoryCopyValue = !canEdit ? categoryValue : undefined; + const cardCopyValue = cardProgramName; + const taxRateValue = taxRateTitle ?? fallbackTaxRateTitle; + const taxRateCopyValue = !canEditTaxFields ? taxRateValue : undefined; + const taxAmountTitle = formattedTaxAmount ? formattedTaxAmount.toString() : ''; + const taxAmountCopyValue = !canEditTaxFields ? taxAmountTitle : undefined; + const distanceRequestFields = ( <> @@ -467,7 +481,8 @@ function MoneyRequestView({ ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction.transactionID, report.reportID, getReportRHPActiveRoute()), ); }} - copyValue={!canEditDistance ? distanceToDisplay : undefined} + copyValue={distanceCopyValue} + copyable={!!distanceCopyValue} /> @@ -493,7 +508,8 @@ function MoneyRequestView({ }} brickRoadIndicator={getErrorForField('customUnitRateID') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('customUnitRateID')} - copyValue={!canEditDistanceRate ? rateToDisplay : undefined} + copyValue={distanceRateCopyValue} + copyable={!!distanceRateCopyValue} /> @@ -514,6 +530,11 @@ function MoneyRequestView({ setCurrentTransactionTag(transactionTag); }, [transactionTag, previousTransactionTag]); + const getAttendeesTitle = useMemo(() => { + return Array.isArray(actualAttendees) ? actualAttendees.map((item) => item?.displayName ?? item?.login).join(', ') : ''; + }, [transactionAttendees]); + const attendeesCopyValue = !canEdit ? getAttendeesTitle : undefined; + const previousTagLength = getLengthOfTag(previousTag ?? ''); const currentTagLength = getLengthOfTag(currentTransactionTag ?? ''); @@ -544,6 +565,7 @@ function MoneyRequestView({ hasDependentTags, tagForDisplay, ); + const tagCopyValue = !canEdit ? tagForDisplay : undefined; return ( ); @@ -577,6 +601,7 @@ function MoneyRequestView({ const actualParentReport = isFromMergeTransaction ? getReportOrDraftReport(getReportIDForExpense(updatedTransaction)) : parentReport; const shouldShowReport = !!parentReportID || !!actualParentReport; + const reportCopyValue = !canEditReport ? getReportName(actualParentReport) || actualParentReport?.reportName : undefined; // In this case we want to use this value. The shouldUseNarrowLayout will always be true as this case is handled when we display ReportScreen in RHP. // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth @@ -642,6 +667,8 @@ function MoneyRequestView({ }} brickRoadIndicator={getErrorForField('amount') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('amount')} + copyValue={amountCopyValue} + copyable={!!amountCopyValue} /> @@ -661,6 +688,8 @@ function MoneyRequestView({ brickRoadIndicator={getErrorForField('comment') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('comment')} numberOfLinesTitle={0} + copyValue={descriptionCopyValue} + copyable={!!descriptionCopyValue} /> {isManualDistanceRequest || (isMapDistanceRequest && transaction?.comment?.waypoints) ? ( @@ -682,7 +711,8 @@ function MoneyRequestView({ brickRoadIndicator={getErrorForField('merchant') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('merchant')} numberOfLinesTitle={0} - copyValue={!canEditMerchant ? updatedMerchantTitle : undefined} + copyValue={merchantCopyValue} + copyable={!!merchantCopyValue} /> )} @@ -700,14 +730,15 @@ function MoneyRequestView({ }} brickRoadIndicator={getErrorForField('date') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('date')} - copyValue={!canEditDate ? transactionDate : undefined} + copyValue={dateCopyValue} + copyable={!!dateCopyValue} /> {!!shouldShowCategory && ( )} @@ -740,16 +773,18 @@ function MoneyRequestView({ )} {shouldShowTax && ( )} {shouldShowTax && ( )} @@ -784,7 +823,7 @@ function MoneyRequestView({ item?.displayName ?? item?.login).join(', ') : ''} + title={getAttendeesTitle} description={`${translate('iou.attendees')} ${ Array.isArray(actualAttendees) && actualAttendees.length > 1 && formattedPerAttendeeAmount ? `${CONST.DOT_SEPARATOR} ${formattedPerAttendeeAmount} ${translate('common.perPerson')}` @@ -798,6 +837,8 @@ function MoneyRequestView({ interactive={canEdit} shouldShowRightIcon={canEdit} shouldRenderAsHTML + copyValue={attendeesCopyValue} + copyable={!!attendeesCopyValue} /> )} @@ -878,6 +919,8 @@ function MoneyRequestView({ }} interactive={canEditReport} shouldRenderAsHTML + copyValue={reportCopyValue} + copyable={!!reportCopyValue} /> )} diff --git a/src/pages/workspace/WorkspaceOverviewPage.tsx b/src/pages/workspace/WorkspaceOverviewPage.tsx index 9363bf866006..fd576dc7647c 100644 --- a/src/pages/workspace/WorkspaceOverviewPage.tsx +++ b/src/pages/workspace/WorkspaceOverviewPage.tsx @@ -470,6 +470,7 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa wrapperStyle={styles.sectionMenuItemTopDescription} onPress={onPressAddress} copyValue={readOnly ? formattedAddress : undefined} + copyable={readOnly && !!formattedAddress} />