Skip to content

Commit

Permalink
Merge pull request #46858 from hungvu193/chore-46303
Browse files Browse the repository at this point in the history
Clean-up some logic with invoice report fields
  • Loading branch information
mountiny authored Aug 12, 2024
2 parents 4ef1202 + 35cc8f4 commit 00057ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function MoneyReportView({report, policy, isCombinedReport = false, shouldShowTo

const sortedPolicyReportFields = useMemo<PolicyReportField[]>((): PolicyReportField[] => {
const fields = ReportUtils.getAvailableReportFields(report, Object.values(policy?.fieldList ?? {}));
return fields.sort(({orderWeight: firstOrderWeight}, {orderWeight: secondOrderWeight}) => firstOrderWeight - secondOrderWeight);
return fields.filter((field) => field.target === report.type).sort(({orderWeight: firstOrderWeight}, {orderWeight: secondOrderWeight}) => firstOrderWeight - secondOrderWeight);
}, [policy, report]);

const enabledReportFields = sortedPolicyReportFields.filter((reportField) => !ReportUtils.isReportFieldDisabled(report, reportField, policy));
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,9 @@ type PolicyReportField = {
/** Value of the field */
value?: string | null;

/** Value of the target */
target?: 'expense' | 'invoice' | 'paycheck';

/** Options to select from if field is of type dropdown */
values: string[];

Expand Down

0 comments on commit 00057ea

Please sign in to comment.