Skip to content

Commit

Permalink
show the payable amount
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Jul 4, 2024
1 parent a84f68e commit 0f1a618
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function ReportPreview({
const [isHoldMenuVisible, setIsHoldMenuVisible] = useState(false);
const [requestType, setRequestType] = useState<ActionHandledType>();
const [nonHeldAmount, fullAmount] = ReportUtils.getNonHeldAndFullAmount(iouReport, policy);
const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(iouReport?.reportID ?? '');
const {isSmallScreenWidth} = useWindowDimensions();
const [paymentType, setPaymentType] = useState<PaymentMethodType>();

Expand Down Expand Up @@ -204,6 +205,18 @@ function ReportPreview({
}
};

const getSettlementAmount = () => {
if (hasOnlyHeldExpenses) {
return '';
}

if (ReportUtils.hasHeldExpenses(iouReport?.reportID) && canAllowSettlement) {
return nonHeldAmount;
}

return CurrencyUtils.convertToDisplayString(reimbursableSpend, iouReport?.currency);
}

const getDisplayAmount = (): string => {
if (totalDisplaySpend) {
return CurrencyUtils.convertToDisplayString(totalDisplaySpend, iouReport?.currency);
Expand Down Expand Up @@ -415,7 +428,7 @@ function ReportPreview({
</View>
{shouldShowSettlementButton && (
<SettlementButton
formattedAmount={getDisplayAmount() ?? ''}
formattedAmount={getSettlementAmount() ?? ''}
currency={iouReport?.currency}
policyID={policyID}
chatReportID={chatReportID}
Expand Down Expand Up @@ -455,7 +468,7 @@ function ReportPreview({
</View>
{isHoldMenuVisible && iouReport && requestType !== undefined && (
<ProcessMoneyReportHoldMenu
nonHeldAmount={!ReportUtils.hasOnlyHeldExpenses(iouReport?.reportID ?? '') ? nonHeldAmount : undefined}
nonHeldAmount={!hasOnlyHeldExpenses ? nonHeldAmount : undefined}
requestType={requestType}
fullAmount={fullAmount}
isSmallScreenWidth={isSmallScreenWidth}
Expand Down

0 comments on commit 0f1a618

Please sign in to comment.