Skip to content

Commit

Permalink
Merge pull request Expensify#52556 from callstack-internal/feature/51…
Browse files Browse the repository at this point in the history
…528-multiple-invoices-page

Allow invoices with multiple expenses
  • Loading branch information
cristipaval authored Dec 11, 2024
2 parents 8f18f39 + fa8ec14 commit ec76adc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/components/ReportActionItem/MoneyReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo

const enabledReportFields = sortedPolicyReportFields.filter((reportField) => !ReportUtils.isReportFieldDisabled(report, reportField, policy));
const isOnlyTitleFieldEnabled = enabledReportFields.length === 1 && ReportUtils.isReportFieldOfTypeTitle(enabledReportFields.at(0));
const shouldShowReportField =
!ReportUtils.isClosedExpenseReportWithNoExpenses(report) && ReportUtils.isPaidGroupPolicyExpenseReport(report) && (!isCombinedReport || !isOnlyTitleFieldEnabled);
const isClosedExpenseReportWithNoExpenses = ReportUtils.isClosedExpenseReportWithNoExpenses(report);
const isPaidGroupPolicyExpenseReport = ReportUtils.isPaidGroupPolicyExpenseReport(report);
const isInvoiceReport = ReportUtils.isInvoiceReport(report);
const shouldShowReportField = !isClosedExpenseReportWithNoExpenses && (isPaidGroupPolicyExpenseReport || isInvoiceReport) && (!isCombinedReport || !isOnlyTitleFieldEnabled);

const renderThreadDivider = useMemo(
() =>
Expand All @@ -102,9 +104,9 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo
<>
<View style={[styles.pRelative]}>
<AnimatedEmptyStateBackground />
{!ReportUtils.isClosedExpenseReportWithNoExpenses(report) && (
{!isClosedExpenseReportWithNoExpenses && (
<>
{ReportUtils.isPaidGroupPolicyExpenseReport(report) &&
{(isPaidGroupPolicyExpenseReport || isInvoiceReport) &&
policy?.areReportFieldsEnabled &&
(!isCombinedReport || !isOnlyTitleFieldEnabled) &&
sortedPolicyReportFields.map((reportField) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/SelectionList/Search/ReportListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function TotalCell({showTooltip, isLargeScreenWidth, reportItem}: ReportCellProp

// Only invert non-zero values otherwise we'll end up with -0.00
if (total) {
total *= reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1;
total *= reportItem?.type === CONST.REPORT.TYPE.EXPENSE || reportItem?.type === CONST.REPORT.TYPE.INVOICE ? -1 : 1;
}

return (
Expand Down
4 changes: 4 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4050,6 +4050,10 @@ function getReportName(
}

if (isInvoiceReport(report)) {
if (!isInvoiceRoom(getReport(report?.chatReportID ?? ''))) {
return report?.reportName ?? getMoneyRequestReportName(report, policy, invoiceReceiverPolicy);
}

formattedName = getMoneyRequestReportName(report, policy, invoiceReceiverPolicy);
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/EditReportFieldPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function EditReportFieldPage({route}: EditReportFieldPageProps) {
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
const {translate} = useLocalize();
const isReportFieldTitle = ReportUtils.isReportFieldOfTypeTitle(reportField);
const reportFieldsEnabled = (ReportUtils.isPaidGroupPolicyExpenseReport(report) && !!policy?.areReportFieldsEnabled) || isReportFieldTitle;
const reportFieldsEnabled = ((ReportUtils.isPaidGroupPolicyExpenseReport(report) || ReportUtils.isInvoiceReport(report)) && !!policy?.areReportFieldsEnabled) || isReportFieldTitle;

if (!reportFieldsEnabled || !reportField || !policyField || !report || isDisabled) {
return (
Expand Down
11 changes: 11 additions & 0 deletions src/pages/home/report/ReportActionItemSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ function ReportActionItemSingle({
const reportIcons = ReportUtils.getIcons(report, {});

secondaryAvatar = reportIcons.at(avatarIconIndex) ?? {name: '', source: '', type: CONST.ICON_TYPE_AVATAR};
} else if (ReportUtils.isInvoiceReport(iouReport)) {
const secondaryAccountId = iouReport?.managerID ?? -1;
const secondaryUserAvatar = personalDetails?.[secondaryAccountId ?? -1]?.avatar ?? FallbackAvatar;
const secondaryDisplayName = ReportUtils.getDisplayNameForParticipant(secondaryAccountId);

secondaryAvatar = {
source: secondaryUserAvatar,
type: CONST.ICON_TYPE_AVATAR,
name: secondaryDisplayName,
id: secondaryAccountId,
};
} else {
secondaryAvatar = {name: '', source: '', type: 'avatar'};
}
Expand Down

0 comments on commit ec76adc

Please sign in to comment.