Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5bee8d0
working on IOU type fix
sumo-slonik Jul 14, 2025
a628522
Merge branch 'main' into feature/kuba-nowakowski/Update-the-new-repor…
sumo-slonik Jul 14, 2025
67b7c00
revert the revert of empty state (without translations)
sumo-slonik Jul 14, 2025
c9b7cdf
add translations
sumo-slonik Jul 14, 2025
b18bb0b
remove debuggers
sumo-slonik Jul 14, 2025
29e171b
remove import arePaymentsEnabled
sumo-slonik Jul 14, 2025
19119c8
add canAddOrDelete condition to empty report
sumo-slonik Jul 15, 2025
54b1bd3
add missing comments
sumo-slonik Jul 15, 2025
b812d26
fix import
sumo-slonik Jul 15, 2025
69bdb0f
check if report is archived
sumo-slonik Jul 15, 2025
d2e5338
Merge branch 'main' into feature/kuba-nowakowski/Update-the-new-repor…
sumo-slonik Jul 16, 2025
4fe59b0
fix tsx and unit
sumo-slonik Jul 16, 2025
17a5c0f
add jest test
sumo-slonik Jul 16, 2025
77f4505
change comment in new utils condition
sumo-slonik Jul 16, 2025
7d73bce
Merge branch 'main' into feature/kuba-nowakowski/Update-the-new-repor…
zfurtak Sep 12, 2025
45dd69b
Adjust code after merge
zfurtak Sep 12, 2025
ab2b394
fix lint
zfurtak Sep 12, 2025
0ec9f43
Merge branch 'main' into feature/kuba-nowakowski/Update-the-new-repor…
zfurtak Sep 19, 2025
9760e5c
Merge branch 'main' into feature/kuba-nowakowski/Update-the-new-repor…
zfurtak Sep 22, 2025
a10bc1c
Merge branch 'main' into feature/kuba-nowakowski/Update-the-new-repor…
zfurtak Sep 22, 2025
f1b624e
Merge branch 'main' into feature/kuba-nowakowski/Update-the-new-repor…
zfurtak Sep 24, 2025
cd99604
Merge branch 'main' into feature/kuba-nowakowski/Update-the-new-repor…
sumo-slonik Sep 26, 2025
07f5b98
fix centring of container
sumo-slonik Sep 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,6 @@ const CONST = {
REMOVE_HOLD: 'removeHold',
REVIEW_DUPLICATES: 'reviewDuplicates',
MARK_AS_CASH: 'markAsCash',
MARK_AS_RESOLVED: 'markAsResolved',
ADD_EXPENSE: 'addExpense',
},
TRANSACTION_PRIMARY_ACTIONS: {
REMOVE_HOLD: 'removeHold',
Expand Down
39 changes: 26 additions & 13 deletions src/components/EmptyStateComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import isEmpty from 'lodash/isEmpty';
import React, {useMemo, useState} from 'react';
import {View} from 'react-native';
import Button from '@components/Button';
import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
import ImageSVG from '@components/ImageSVG';
import Lottie from '@components/Lottie';
import Text from '@components/Text';
Expand Down Expand Up @@ -114,19 +115,31 @@ function EmptyStateComponent({
))}
{children}
{!isEmpty(buttons) && (
<View style={[styles.gap2, styles.mt5, !shouldUseNarrowLayout ? styles.flexRow : styles.flexColumn]}>
{buttons?.map(({buttonText, buttonAction, success, icon, isDisabled, style}) => (
<Button
key={buttonText}
success={success}
onPress={buttonAction}
text={buttonText}
icon={icon}
large
isDisabled={isDisabled}
style={[styles.flex1, style]}
/>
))}
<View style={[styles.gap2, styles.mt5, !shouldUseNarrowLayout ? styles.flexRow : styles.flexColumn, styles.justifyContentCenter]}>
{buttons?.map(({buttonText, buttonAction, success, icon, isDisabled, style, dropDownOptions}) =>
dropDownOptions ? (
<ButtonWithDropdownMenu
key={buttonText}
onPress={() => {}}
shouldAlwaysShowDropdownMenu
customText={buttonText}
options={dropDownOptions}
isSplitButton={false}
style={[styles.flex1, style]}
/>
) : (
<Button
key={buttonText}
success={success}
onPress={buttonAction}
text={buttonText}
icon={icon}
large
isDisabled={isDisabled}
style={[styles.flex1, style]}
/>
),
)}
</View>
)}
</View>
Expand Down
11 changes: 10 additions & 1 deletion src/components/EmptyStateComponent/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {ImageStyle} from 'expo-image';
import type {StyleProp, TextStyle, ViewStyle} from 'react-native';
import type {ValueOf} from 'type-fest';
import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types';
import type DotLottieAnimation from '@components/LottieAnimations/types';
import type SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton';
import type TableRowSkeleton from '@components/Skeletons/TableRowSkeleton';
Expand All @@ -9,7 +10,15 @@ import type IconAsset from '@src/types/utils/IconAsset';

type ValidSkeletons = typeof SearchRowSkeleton | typeof TableRowSkeleton;
type MediaTypes = ValueOf<typeof CONST.EMPTY_STATE_MEDIA>;
type EmptyStateButton = {buttonText?: string; buttonAction?: () => void; success?: boolean; icon?: IconAsset; isDisabled?: boolean; style?: StyleProp<ViewStyle>};
type EmptyStateButton = {
buttonText?: string;
buttonAction?: () => void;
success?: boolean;
icon?: IconAsset;
isDisabled?: boolean;
style?: StyleProp<ViewStyle>;
dropDownOptions?: Array<DropdownOption<ValueOf<{readonly CREATE_NEW_EXPENSE: 'createNewExpense'; readonly ADD_UNREPORTED_EXPENSE: 'addUnreportedExpense'}>>>;
};

type SharedProps<T> = {
SkeletonComponent?: ValidSkeletons;
Expand Down
9 changes: 0 additions & 9 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -820,15 +820,6 @@ function MoneyReportHeader({
}}
/>
),
[CONST.REPORT.PRIMARY_ACTIONS.ADD_EXPENSE]: (
<ButtonWithDropdownMenu
onPress={() => {}}
shouldAlwaysShowDropdownMenu
customText={translate('iou.addExpense')}
options={addExpenseDropdownOptions}
isSplitButton={false}
/>
),
};

const beginPDFExport = (reportID: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import FlatList from '@components/FlatList';
import {AUTOSCROLL_TO_TOP_THRESHOLD} from '@components/InvertedFlatList/BaseInvertedFlatList';
import {usePersonalDetails} from '@components/OnyxListItemProvider';
import {PressableWithFeedback} from '@components/Pressable';
import ScrollView from '@components/ScrollView';
import {useSearchContext} from '@components/Search/SearchContext';
import Text from '@components/Text';
import useLoadReportActions from '@hooks/useLoadReportActions';
Expand Down Expand Up @@ -705,13 +706,16 @@ function MoneyRequestReportActionsList({
onClick={scrollToBottomAndMarkReportAsRead}
/>
{isEmpty(visibleReportActions) && isEmpty(transactions) && !showReportActionsLoadingState ? (
<>
<ScrollView contentContainerStyle={styles.flexGrow1}>
<MoneyRequestViewReportFields
report={report}
policy={policy}
/>
<SearchMoneyRequestReportEmptyState />
</>
<SearchMoneyRequestReportEmptyState
report={report}
policy={policy}
/>
</ScrollView>
) : (
<FlatList
initialNumToRender={INITIAL_NUM_TO_RENDER}
Expand Down Expand Up @@ -742,6 +746,7 @@ function MoneyRequestReportActionsList({
hasComments={reportHasComments}
isLoadingInitialReportActions={showReportActionsLoadingState}
scrollToNewTransaction={scrollToNewTransaction}
policy={policy}
/>
</>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ import MoneyRequestReportTransactionItem from './MoneyRequestReportTransactionIt
import SearchMoneyRequestReportEmptyState from './SearchMoneyRequestReportEmptyState';

type MoneyRequestReportTransactionListProps = {
/** The money request report containing the transactions */
report: OnyxTypes.Report;

/** The workspace to which the report belongs */
policy?: OnyxTypes.Policy;

/** List of transactions belonging to one report */
transactions: OnyxTypes.Transaction[];

Expand Down Expand Up @@ -123,6 +127,7 @@ function MoneyRequestReportTransactionList({
hasComments,
isLoadingInitialReportActions: isLoadingReportActions,
scrollToNewTransaction,
policy,
}: MoneyRequestReportTransactionListProps) {
useCopySelectionHelper();
const styles = useThemeStyles();
Expand Down Expand Up @@ -273,7 +278,10 @@ function MoneyRequestReportTransactionList({
if (isEmptyTransactions) {
return (
<>
<SearchMoneyRequestReportEmptyState />
<SearchMoneyRequestReportEmptyState
report={report}
policy={policy}
/>
<MoneyRequestReportTotalSpend
hasComments={hasComments}
isLoadingReportActions={!!isLoadingReportActions}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,59 @@
import React from 'react';
import {View} from 'react-native';
import EmptyStateComponent from '@components/EmptyStateComponent';
import * as Expensicons from '@components/Icon/Expensicons';
import LottieAnimations from '@components/LottieAnimations';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useThemeStyles from '@hooks/useThemeStyles';
import {canAddTransaction, isArchivedReport} from '@libs/ReportUtils';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import Navigation from '@navigation/Navigation';
import {startMoneyRequest} from '@userActions/IOU';
import {openUnreportedExpense} from '@userActions/Report';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type * as OnyxTypes from '@src/types/onyx';

const minModalHeight = 380;

function SearchMoneyRequestReportEmptyState() {
function SearchMoneyRequestReportEmptyState({report, policy}: {report: OnyxTypes.Report; policy?: OnyxTypes.Policy}) {
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`, {canBeMissing: true});
const {translate} = useLocalize();
const styles = useThemeStyles();
const reportId = report.reportID;
const isReportArchived = isArchivedReport(reportNameValuePairs);
const canAddTransactionToReport = canAddTransaction(report, isReportArchived);
const addExpenseDropdownOptions = [
{
value: CONST.REPORT.ADD_EXPENSE_OPTIONS.CREATE_NEW_EXPENSE,
text: translate('iou.createExpense'),
icon: Expensicons.Plus,
onSelected: () => {
if (!reportId) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, reportId);
},
},
{
value: CONST.REPORT.ADD_EXPENSE_OPTIONS.ADD_UNREPORTED_EXPENSE,
text: translate('iou.addUnreportedExpense'),
icon: Expensicons.ReceiptPlus,
onSelected: () => {
if (policy && shouldRestrictUserBillableActions(policy.id)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
openUnreportedExpense(reportId);
},
},
];

return (
<View style={styles.flex1}>
Expand All @@ -20,11 +63,16 @@ function SearchMoneyRequestReportEmptyState() {
headerMediaType={CONST.EMPTY_STATE_MEDIA.ANIMATION}
headerMedia={LottieAnimations.GenericEmptyState}
title={translate('search.moneyRequestReport.emptyStateTitle')}
subtitle={translate('search.moneyRequestReport.emptyStateSubtitle')}
subtitle={canAddTransactionToReport ? translate('search.moneyRequestReport.emptyStateSubtitle') : ''}
headerStyles={[styles.emptyStateMoneyRequestReport]}
lottieWebViewStyles={styles.emptyStateFolderWebStyles}
headerContentStyles={styles.emptyStateFolderWebStyles}
minModalHeight={minModalHeight}
buttons={
canAddTransactionToReport
? [{buttonText: translate('iou.addExpense'), buttonAction: () => {}, success: true, isDisabled: false, dropDownOptions: addExpenseDropdownOptions}]
: []
}
/>
</View>
);
Expand Down
3 changes: 2 additions & 1 deletion src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6212,7 +6212,8 @@ const translations = {
groupBy: 'Gruppe nach',
moneyRequestReport: {
emptyStateTitle: 'Dieser Bericht enthält keine Ausgaben.',
emptyStateSubtitle: 'Sie können Ausgaben zu diesem Bericht hinzufügen, indem Sie die Schaltfläche oben verwenden.',
emptyStateSubtitle:
'Sie können diesem Bericht Ausgaben hinzufügen,\n indem Sie auf die Schaltfläche unten klicken oder die Option „Ausgabe hinzufügen“ im Menü „Mehr“ oben verwenden.',
},
noCategory: 'Keine Kategorie',
noTag: 'Kein Tag',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6178,7 +6178,7 @@ const translations = {
groupBy: 'Group by',
moneyRequestReport: {
emptyStateTitle: 'This report has no expenses.',
emptyStateSubtitle: 'You can add expenses to this report \n using the button above.',
emptyStateSubtitle: 'You can add expenses to this report \n using the button below or the "Add expense" option in the More menu above.',
},
noCategory: 'No category',
noTag: 'No tag',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6199,7 +6199,7 @@ const translations = {
groupBy: 'Agrupar por',
moneyRequestReport: {
emptyStateTitle: 'Este informe no tiene gastos.',
emptyStateSubtitle: 'Puedes añadir gastos a este informe usando el botón de arriba.',
emptyStateSubtitle: 'Puedes agregar gastos a este informe\n usando el botón de abajo o la opción "Agregar gasto" en el menú Más de arriba.',
},
noCategory: 'Sin categoría',
noTag: 'Sin etiqueta',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6220,7 +6220,7 @@ const translations = {
groupBy: 'Groupe par',
moneyRequestReport: {
emptyStateTitle: "Ce rapport n'a pas de dépenses.",
emptyStateSubtitle: 'Vous pouvez ajouter des dépenses à ce rapport en utilisant le bouton ci-dessus.',
emptyStateSubtitle: "Vous pouvez ajouter des dépenses à ce rapport\n en utilisant le bouton ci-dessous ou l'option « Ajouter une dépense » dans le menu Plus ci-dessus.",
},
noCategory: 'Aucune catégorie',
noTag: 'Aucun tag',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6223,7 +6223,7 @@ const translations = {
groupBy: 'Gruppo per',
moneyRequestReport: {
emptyStateTitle: 'Questo report non ha spese.',
emptyStateSubtitle: 'Puoi aggiungere spese a questo rapporto utilizzando il pulsante sopra.',
emptyStateSubtitle: 'Puoi aggiungere spese a questo report\n utilizzando il pulsante in basso o l\'opzione "Aggiungi spesa" nel menu Altro sopra.',
},
noCategory: 'Nessuna categoria',
noTag: 'Nessun tag',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6164,7 +6164,7 @@ const translations = {
groupBy: 'グループ',
moneyRequestReport: {
emptyStateTitle: 'このレポートには経費がありません。',
emptyStateSubtitle: 'このレポートに経費を追加するには、上のボタンを使用してください。',
emptyStateSubtitle: 'このレポートに経費を追加するには、\n 下のボタンを使用するか、上の「その他」メニューから「経費を追加」を選択してください。',
},
noCategory: 'カテゴリなし',
noTag: 'タグなし',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6208,7 +6208,7 @@ const translations = {
groupBy: 'Groep per',
moneyRequestReport: {
emptyStateTitle: 'Dit rapport heeft geen uitgaven.',
emptyStateSubtitle: 'Je kunt uitgaven aan dit rapport toevoegen met de knop hierboven.',
emptyStateSubtitle: 'U kunt uitgaven aan dit rapport toevoegen\n via de knop hieronder of de optie "Uitgave toevoegen" in het menu Meer hierboven.',
},
noCategory: 'Geen categorie',
noTag: 'Geen tag',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6195,7 +6195,7 @@ const translations = {
groupBy: 'Grupa według',
moneyRequestReport: {
emptyStateTitle: 'Ten raport nie zawiera wydatków.',
emptyStateSubtitle: 'Możesz dodać wydatki do tego raportu, używając przycisku powyżej.',
emptyStateSubtitle: 'Możesz dodać wydatki do tego raportu\n za pomocą przycisku poniżej lub opcji „Dodaj wydatek” w menu Więcej powyżej.',
},
noCategory: 'Brak kategorii',
noTag: 'Brak tagu',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6209,7 +6209,7 @@ const translations = {
groupBy: 'Agrupar por',
moneyRequestReport: {
emptyStateTitle: 'Este relatório não possui despesas.',
emptyStateSubtitle: 'Você pode adicionar despesas a este relatório usando o botão acima.',
emptyStateSubtitle: 'Você pode adicionar despesas a este relatório\n usando o botão abaixo ou a opção "Adicionar despesa" no menu Mais acima.',
},
noCategory: 'Sem categoria',
noTag: 'Sem etiqueta',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6086,7 +6086,7 @@ const translations = {
groupBy: '组别',
moneyRequestReport: {
emptyStateTitle: '此报告没有费用。',
emptyStateSubtitle: '您可以使用上面的按钮将费用添加到此报告中。',
emptyStateSubtitle: '您可以使用下方按钮,或上方“更多”菜单中的“添加费用”选项,将费用添加到此报告中。',
},
noCategory: '无类别',
noTag: '无标签',
Expand Down
8 changes: 0 additions & 8 deletions src/libs/ReportPrimaryActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,6 @@ function getReportPrimaryAction(params: GetReportPrimaryActionParams): ValueOf<t

const isPayActionWithAllExpensesHeld = isPrimaryPayAction(report, policy, reportNameValuePairs, isChatReportArchived) && hasOnlyHeldExpenses(report?.reportID);

if (isMarkAsResolvedReportAction(report, chatReport, reportTransactions, violations, policy, reportActions)) {
return CONST.REPORT.PRIMARY_ACTIONS.MARK_AS_RESOLVED;
}

if (isAddExpenseAction(report, reportTransactions, isChatReportArchived)) {
return CONST.REPORT.PRIMARY_ACTIONS.ADD_EXPENSE;
}

if (isMarkAsCashAction(report, reportTransactions, violations, policy)) {
return CONST.REPORT.PRIMARY_ACTIONS.MARK_AS_CASH;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportSecondaryActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {
function isAddExpenseAction(report: Report, reportTransactions: Transaction[], isReportArchived = false) {
const isReportSubmitter = isCurrentUserSubmitter(report);

if (!isReportSubmitter || reportTransactions.length === 0) {
if (!isReportSubmitter) {
return false;
}

Expand Down
Loading
Loading