Skip to content

Commit

Permalink
Merge pull request #44838 from bernhardoj/fix/44158-show-payable-amou…
Browse files Browse the repository at this point in the history
…nt-on-report-preview-pay-btn

Fix different amount shown in pay buttons between report preview and expense report header
  • Loading branch information
dangrous authored Jul 12, 2024
2 parents 1048f9a + 8887a46 commit eb49e72
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 @@ -203,6 +204,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 @@ -405,7 +418,7 @@ function ReportPreview({
</View>
{shouldShowSettlementButton && (
<SettlementButton
formattedAmount={getDisplayAmount() ?? ''}
formattedAmount={getSettlementAmount() ?? ''}
currency={iouReport?.currency}
policyID={policyID}
chatReportID={chatReportID}
Expand Down Expand Up @@ -445,7 +458,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 eb49e72

Please sign in to comment.