diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 33ad99f32326..b10b8d87cabd 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -104,12 +104,13 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor formattedTransactionAmount = translate('common.tbd'); } const formattedOriginalAmount = transactionOriginalAmount && transactionOriginalCurrency && CurrencyUtils.convertToDisplayString(transactionOriginalAmount, transactionOriginalCurrency); - const isExpensifyCardTransaction = TransactionUtils.isExpensifyCardTransaction(transaction); - const cardProgramName = isExpensifyCardTransaction ? CardUtils.getCardDescription(transactionCardID) : ''; + const isCardTransaction = TransactionUtils.isCardTransaction(transaction); + const cardProgramName = isCardTransaction ? CardUtils.getCardDescription(transactionCardID) : ''; // Flags for allowing or disallowing editing a money request const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID); - const canEdit = ReportUtils.canEditMoneyRequest(parentReportAction) && !isExpensifyCardTransaction; + const canEdit = ReportUtils.canEditMoneyRequest(parentReportAction); + const canEditAmount = canEdit && !isSettled && !isCardTransaction; // A flag for verifying that the current report is a sub-report of a workspace chat const isPolicyExpenseChat = useMemo(() => ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)), [report]); @@ -125,7 +126,7 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor let amountDescription = `${translate('iou.amount')}`; - if (isExpensifyCardTransaction) { + if (isCardTransaction) { if (formattedOriginalAmount) { amountDescription += ` • ${translate('iou.original')} ${formattedOriginalAmount}`; } @@ -190,8 +191,8 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor titleIcon={Expensicons.Checkmark} description={amountDescription} titleStyle={styles.newKansasLarge} - interactive={canEdit && !isSettled} - shouldShowRightIcon={canEdit && !isSettled} + interactive={canEditAmount} + shouldShowRightIcon={canEditAmount} onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.AMOUNT))} brickRoadIndicator={hasErrors && transactionAmount === 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} error={hasErrors && transactionAmount === 0 ? translate('common.error.enterAmount') : ''} @@ -271,13 +272,12 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor /> )} - {isExpensifyCardTransaction && ( + {isCardTransaction && ( )} diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index 00ce8c55dbd7..baf4ba6fb2f8 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -330,6 +330,13 @@ function isExpensifyCardTransaction(transaction: Transaction): boolean { return isExpensifyCard(transaction.cardID); } +/** + * Determine whether a transaction is made with a card. + */ +function isCardTransaction(transaction: Transaction): boolean { + return (transaction?.cardID ?? 0) > 0; +} + /** * Check if the transaction status is set to Pending. */ @@ -475,6 +482,7 @@ export { getValidWaypoints, isDistanceRequest, isExpensifyCardTransaction, + isCardTransaction, isPending, isPosted, getWaypoints,