Skip to content

Commit a63f963

Browse files
authored
Merge pull request #90882 from Expensify/claude-blockNegativeSignIouReport
Block negative sign for IOU expense inline editing in IOU report
2 parents b04f39e + eb27a8d commit a63f963

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/components/TransactionItemRow/DataCells/TotalCell.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ import {parseFloatAnyLocale, roundToTwoDecimalPlaces} from '@libs/NumberUtils';
1414
import {getTransactionDetails, isInvoiceReport, shouldEnableNegative} from '@libs/ReportUtils';
1515
import {getCurrency as getTransactionCurrency, isDeletedTransaction, isExpenseUnreported, isScanning} from '@libs/TransactionUtils';
1616
import CONST from '@src/CONST';
17+
import type {Policy, Report} from '@src/types/onyx';
1718
import type TransactionDataCellProps from './TransactionDataCellProps';
1819

19-
type TotalCellProps = TransactionDataCellProps & EditableProps<number>;
20+
type TotalCellProps = TransactionDataCellProps &
21+
EditableProps<number> & {
22+
/** Report passed explicitly (used in IOU report view where transactionItem.report may be undefined) */
23+
report?: Report;
24+
25+
/** Policy passed explicitly (used in IOU report view where transactionItem.policy may be undefined) */
26+
policy?: Policy;
27+
};
2028
type TransactionItem = TransactionDataCellProps['transactionItem'];
2129

2230
function getTransactionItemIouType(transactionItem: TransactionItem) {
@@ -28,7 +36,7 @@ function getTransactionItemIouType(transactionItem: TransactionItem) {
2836
return isSplitTransaction ? CONST.IOU.TYPE.SPLIT : CONST.IOU.TYPE.SUBMIT;
2937
}
3038

31-
function TotalCell({shouldShowTooltip, transactionItem, canEdit, onSave}: TotalCellProps) {
39+
function TotalCell({shouldShowTooltip, transactionItem, canEdit, onSave, report, policy}: TotalCellProps) {
3240
const styles = useThemeStyles();
3341
const {translate, preferredLocale} = useLocalize();
3442
const {convertToDisplayString} = useCurrencyListActions();
@@ -41,10 +49,12 @@ function TotalCell({shouldShowTooltip, transactionItem, canEdit, onSave}: TotalC
4149
amountToDisplay = translate('iou.receiptStatusTitle');
4250
}
4351

44-
const iouType = getTransactionItemIouType(transactionItem);
52+
const effectiveReport = report ?? transactionItem.report;
53+
const effectivePolicy = policy ?? transactionItem.policy;
54+
const iouType = getTransactionItemIouType({...transactionItem, report: effectiveReport});
4555
const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT;
4656
const isUnreportedExpense = isExpenseUnreported(transactionItem);
47-
const allowNegative = isUnreportedExpense || shouldEnableNegative(transactionItem.report, transactionItem.policy, iouType, transactionItem.participants);
57+
const allowNegative = isUnreportedExpense || shouldEnableNegative(effectiveReport, effectivePolicy, iouType, transactionItem.participants);
4858

4959
const absoluteAmount = Math.abs(amount ?? 0);
5060
const isOriginalAmountNegative = (amount ?? 0) < 0;

src/components/TransactionItemRow/TransactionItemRowWide.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ function TransactionItemRowWide({
415415
shouldUseNarrowLayout={false}
416416
canEdit={canEditAmount}
417417
onSave={onEditAmount}
418+
report={report}
419+
policy={policy}
418420
/>
419421
</View>
420422
);

0 commit comments

Comments
 (0)