Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
5326a6f
Add report preview actions to new preview component
jnowakow Apr 7, 2025
6ca8a5f
Fix several blockers after PR-58084
jnowakow Apr 9, 2025
357308a
Merge branch 'main' of github.com:Expensify/App into jnowakow/blocker…
jnowakow Apr 9, 2025
d2be1d5
fix test
jnowakow Apr 9, 2025
6a890dc
Further fixes
jnowakow Apr 9, 2025
c36fc9d
Revert "revert 58084"
jnowakow Apr 10, 2025
ba3eb29
fix 'Download as PDF' option is shown for DM thread
SzymczakJ Apr 10, 2025
228fc50
fix No warning is shown when unapproving an expense that has been exp…
SzymczakJ Apr 10, 2025
59cca89
fix "Pay with Expensify" button extends out of screen
SzymczakJ Apr 10, 2025
6064c5b
fix empty green button on the expense preview when scanning
SzymczakJ Apr 10, 2025
21ee95f
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 11, 2025
515d557
Merge branch 'jnowakow/blockers-after-58084' into jnowakow/simplified…
jnowakow Apr 11, 2025
d9fa312
fix unnecessary delete option
sumo-slonik Apr 11, 2025
27d9378
fix 59904
jnowakow Apr 11, 2025
8e1f56e
add additional violation check to report previews
SzymczakJ Apr 11, 2025
c2a0b2a
fix 59909
jnowakow Apr 11, 2025
a3c084a
fix 59880
borys3kk Apr 11, 2025
6dff03e
Fix 59916
jnowakow Apr 11, 2025
86e9a9d
Merge branch 'jnowakow/simplified-actions-on-header-v2' into borys3kk…
borys3kk Apr 11, 2025
e971067
Merge branch 'main' into jnowakow/simplified-actions-on-header-v2
jnowakow Apr 11, 2025
97321d9
Fix 59928
jnowakow Apr 11, 2025
a6ada46
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 14, 2025
e5d8000
Merge branch 'jnowakow/actions-on-new-preview-component' into jnowako…
jnowakow Apr 14, 2025
ec27757
fix unissued bug
borys3kk Apr 14, 2025
5df34d7
Fix linter, prettier and tests
jnowakow Apr 14, 2025
450817a
Fix prettier 2
jnowakow Apr 14, 2025
6118cd4
Merge pull request #221 from software-mansion-labs/bugfix/kuba_nowako…
sumo-slonik Apr 14, 2025
049eb51
Fix checks
jnowakow Apr 14, 2025
2cd657b
merge commit
SzymczakJ Apr 14, 2025
5f1713c
fix "Review" button is still displayed for admin and employee after e…
SzymczakJ Apr 14, 2025
ab14e9b
clean up code
SzymczakJ Apr 14, 2025
0376896
Merge pull request #222 from software-mansion-labs/@szymczak/fixes-fo…
jnowakow Apr 14, 2025
54e7525
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 15, 2025
1d5af08
fix 59910
borys3kk Apr 15, 2025
7af5b9b
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 15, 2025
5e26bd9
Merge branch 'jnowakow/simplified-actions-on-header-v2' of github.com…
jnowakow Apr 15, 2025
e4e8593
Merge branch 'jnowakow/simplified-actions-on-header-v2' into borys3kk…
borys3kk Apr 15, 2025
4d5e127
Merge pull request #223 from software-mansion-labs/borys3kk-fix-58084…
jnowakow Apr 15, 2025
5396aed
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 16, 2025
1c44254
fix 59899
jnowakow Apr 16, 2025
171d21e
fix 59900
jnowakow Apr 16, 2025
f1044b5
Don't show submit for report with empty transaction
jnowakow Apr 16, 2025
c92d300
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 16, 2025
e726f2c
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 16, 2025
e79d438
Merge branch 'main' into jnowakow/simplified-actions-on-header-v2
jnowakow Apr 17, 2025
c940be8
Update condition to check if message was exported and improve preview…
jnowakow Apr 17, 2025
8361f6e
Check if receipt is being scanned before allowing to submit
jnowakow Apr 17, 2025
78eb183
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 18, 2025
04805a3
fix 59999\#issuecomment-2814714079
jnowakow Apr 18, 2025
611d96e
fix 59999\#issuecomment-2814854160
jnowakow Apr 18, 2025
390d1db
fix 59999\#issuecomment-2814873758
jnowakow Apr 18, 2025
b7832ee
fix 59999\#issuecomment-2814939366
jnowakow Apr 18, 2025
2e39ba8
fix 59999\#issuecomment-2815075448
jnowakow Apr 18, 2025
0ab9d7c
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 22, 2025
172a0f9
Hide new logic behind beta
jnowakow Apr 22, 2025
724a2f0
fix tests
jnowakow Apr 22, 2025
17a6bb1
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 22, 2025
ae9a729
fix typecheck
jnowakow Apr 22, 2025
67e9a4a
fix prettier
jnowakow Apr 22, 2025
a8e8b2a
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 23, 2025
ad97b7c
Check beta on ReportDetailsPage
jnowakow Apr 23, 2025
4428dfa
make tests deterministic
jnowakow Apr 23, 2025
cb19ab8
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 23, 2025
6f9eca2
Do not remove option to export csv from details page
jnowakow Apr 23, 2025
3be336a
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 23, 2025
7311c4a
fix ts
jnowakow Apr 23, 2025
d12b67e
Merge branch 'main' of github.com:Expensify/App into jnowakow/simplif…
jnowakow Apr 24, 2025
44e1cad
after merge
jnowakow Apr 24, 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
18 changes: 18 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,24 @@ const CONST = {
REVIEW_DUPLICATES: 'reviewDuplicates',
MARK_AS_CASH: 'markAsCash',
},
TRANSACTION_PRIMARY_ACTIONS: {
REMOVE_HOLD: 'removeHold',
REVIEW_DUPLICATES: 'reviewDuplicates',
MARK_AS_CASH: 'markAsCash',
},
REPORT_PREVIEW_ACTIONS: {
VIEW: 'view',
REVIEW: 'review',
SUBMIT: 'submit',
APPROVE: 'approve',
PAY: 'pay',
EXPORT_TO_ACCOUNTING: 'exportToAccounting',
},
TRANSACTION_SECONDARY_ACTIONS: {
HOLD: 'hold',
VIEW_DETAILS: 'viewDetails',
DELETE: 'delete',
},
ACTIONS: {
LIMIT: 50,
// OldDot Actions render getMessage from Web-Expensify/lib/Report/Action PHP files via getMessageOfOldDotReportAction in ReportActionsUtils.ts
Expand Down
19 changes: 8 additions & 11 deletions src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import type {Policy, Report} from '@src/types/onyx';
import type {Icon} from '@src/types/onyx/OnyxCommon';
import {getButtonRole} from './Button/utils';
import CaretWrapper from './CaretWrapper';
import DisplayNames from './DisplayNames';
import {FallbackAvatar} from './Icon/Expensicons';
import MultipleAvatars from './MultipleAvatars';
Expand Down Expand Up @@ -64,15 +63,15 @@
};

function AvatarWithDisplayName({policy, report, isAnonymous = false, size = CONST.AVATAR_SIZE.DEFAULT, shouldEnableDetailPageNavigation = false}: AvatarWithDisplayNameProps) {
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`, {canEvict: false});

Check failure on line 66 in src/components/AvatarWithDisplayName.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST) ?? CONST.EMPTY_OBJECT;

const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`);

Check failure on line 72 in src/components/AvatarWithDisplayName.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
const [invoiceReceiverPolicy] = useOnyx(

Check failure on line 73 in src/components/AvatarWithDisplayName.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param
`${ONYXKEYS.COLLECTION.POLICY}${parentReport?.invoiceReceiver && 'policyID' in parentReport.invoiceReceiver ? parentReport.invoiceReceiver.policyID : CONST.DEFAULT_NUMBER_ID}`,

Check failure on line 74 in src/components/AvatarWithDisplayName.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

);
const title = getReportName(report, undefined, undefined, undefined, invoiceReceiverPolicy);
const subtitle = getChatRoomSubtitle(report, {isCreateExpenseFlow: true});
Expand Down Expand Up @@ -155,16 +154,14 @@
</View>
</PressableWithoutFeedback>
<View style={[styles.flex1, styles.flexColumn]}>
<CaretWrapper>
<DisplayNames
fullTitle={title}
displayNamesWithTooltips={displayNamesWithTooltips}
tooltipEnabled
numberOfLines={1}
textStyles={[isAnonymous ? styles.headerAnonymousFooter : styles.headerText, styles.pre]}
shouldUseFullTitle={isMoneyRequestOrReport || isAnonymous}
/>
</CaretWrapper>
<DisplayNames
fullTitle={title}
displayNamesWithTooltips={displayNamesWithTooltips}
tooltipEnabled
numberOfLines={1}
textStyles={[isAnonymous ? styles.headerAnonymousFooter : styles.headerText, styles.pre]}
shouldUseFullTitle={isMoneyRequestOrReport || isAnonymous}
/>
{Object.keys(parentNavigationSubtitleData).length > 0 && (
<ParentNavigationSubtitle
parentNavigationSubtitleData={parentNavigationSubtitleData}
Expand Down
624 changes: 397 additions & 227 deletions src/components/MoneyReportHeader.tsx

Large diffs are not rendered by default.

730 changes: 730 additions & 0 deletions src/components/MoneyReportHeaderOld.tsx

Large diffs are not rendered by default.

196 changes: 149 additions & 47 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import {useRoute} from '@react-navigation/native';
import type {ReactNode} from 'react';
import React, {useCallback, useEffect} from 'react';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useTransactionViolations from '@hooks/useTransactionViolations';
import {deleteMoneyRequest, getNavigationUrlOnMoneyRequestDelete} from '@libs/actions/IOU';
import Navigation from '@libs/Navigation/Navigation';
import {getOriginalMessage, isMoneyRequestAction} from '@libs/ReportActionsUtils';
import {getTransactionThreadPrimaryAction} from '@libs/ReportPrimaryActionUtils';
import {getSecondaryTransactionThreadActions} from '@libs/ReportSecondaryActionUtils';
import {changeMoneyRequestHoldStatus, navigateBackOnDeleteTransaction, navigateToDetailsPage} from '@libs/ReportUtils';
import {
checkIfShouldShowMarkAsCashButton,
hasPendingRTERViolation as hasPendingRTERViolationTransactionUtils,
hasReceipt,
isDuplicate as isDuplicateTransactionUtils,
Expand All @@ -33,6 +37,10 @@ import type IconAsset from '@src/types/utils/IconAsset';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
import BrokenConnectionDescription from './BrokenConnectionDescription';
import Button from './Button';
import ButtonWithDropdownMenu from './ButtonWithDropdownMenu';
import type {DropdownOption} from './ButtonWithDropdownMenu/types';
import ConfirmModal from './ConfirmModal';
import DecisionModal from './DecisionModal';
import HeaderWithBackButton from './HeaderWithBackButton';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
Expand Down Expand Up @@ -68,6 +76,8 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
);
const transactionViolations = useTransactionViolations(transaction?.transactionID);

const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
const [downloadErrorModalVisible, setDownloadErrorModalVisible] = useState(false);
const [dismissedHoldUseExplanation, dismissedHoldUseExplanationResult] = useOnyx(ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, {initialValue: true});
const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA);
const isLoadingHoldUseExplained = isLoadingOnyxValue(dismissedHoldUseExplanationResult);
Expand All @@ -85,7 +95,6 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
const hasPendingRTERViolation = hasPendingRTERViolationTransactionUtils(transactionViolations);

const shouldShowBrokenConnectionViolation = shouldShowBrokenConnectionViolationTransactionUtils(parentReport, policy, transactionViolations);
const shouldShowMarkAsCashButton = checkIfShouldShowMarkAsCashButton(hasPendingRTERViolation, shouldShowBrokenConnectionViolation, parentReport, policy);

const markAsCash = useCallback(() => {
markAsCashAction(transaction?.transactionID, reportID);
Expand Down Expand Up @@ -144,12 +153,89 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
Navigation.navigate(ROUTES.PROCESS_MONEY_REQUEST_HOLD.getRoute(Navigation.getReportRHPActiveRoute()));
}, [dismissedHoldUseExplanation, isLoadingHoldUseExplained, isOnHold]);

const primaryAction = useMemo(() => {
if (!report || !parentReport || !transaction) {
return '';
}
return getTransactionThreadPrimaryAction(report, parentReport, transaction, transactionViolations, policy);
}, [parentReport, policy, report, transaction, transactionViolations]);

const primaryActionImplementation = {
[CONST.REPORT.TRANSACTION_PRIMARY_ACTIONS.REMOVE_HOLD]: (
<Button
success
text={translate('iou.unhold')}
onPress={() => {
changeMoneyRequestHoldStatus(parentReportAction);
}}
/>
),
[CONST.REPORT.TRANSACTION_PRIMARY_ACTIONS.REVIEW_DUPLICATES]: (
<Button
success
text={translate('iou.reviewDuplicates')}
onPress={() => {
if (!reportID) {
return;
}
Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(reportID, Navigation.getReportRHPActiveRoute()));
}}
/>
),
[CONST.REPORT.TRANSACTION_PRIMARY_ACTIONS.MARK_AS_CASH]: (
<Button
success
text={translate('iou.markAsCash')}
onPress={markAsCash}
/>
),
};

const secondaryActions = useMemo(() => {
if (!parentReport || !transaction) {
return [];
}
return getSecondaryTransactionThreadActions(parentReport, transaction);
}, [parentReport, transaction]);

const secondaryActionsImplementation: Record<ValueOf<typeof CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS>, DropdownOption<ValueOf<typeof CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS>>> = {
[CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD]: {
text: translate('iou.hold'),
icon: Expensicons.Stopwatch,
value: CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.HOLD,
onSelected: () => {
if (!parentReportAction) {
throw new Error('Parent action does not exist');
}

changeMoneyRequestHoldStatus(parentReportAction);
},
},
[CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.VIEW_DETAILS]: {
value: CONST.REPORT.SECONDARY_ACTIONS.VIEW_DETAILS,
text: translate('iou.viewDetails'),
icon: Expensicons.Info,
onSelected: () => {
navigateToDetailsPage(report, Navigation.getReportRHPActiveRoute());
},
},
[CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.DELETE]: {
text: translate('common.delete'),
icon: Expensicons.Trashcan,
value: CONST.REPORT.SECONDARY_ACTIONS.DELETE,
onSelected: () => {
setIsDeleteModalVisible(true);
},
},
};

const applicableSecondaryActions = secondaryActions.map((action) => secondaryActionsImplementation[action]);

return (
<View style={[styles.pl0, styles.borderBottom]}>
<HeaderWithBackButton
shouldShowBorderBottom={false}
shouldShowReportAvatarWithDisplay
shouldEnableDetailPageNavigation
shouldShowPinButton={false}
report={
reportID
Expand All @@ -164,53 +250,39 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
shouldShowBackButton={shouldUseNarrowLayout}
shouldDisplaySearchRouter={shouldDisplaySearchRouter}
onBackButtonPress={onBackButtonPress}
shouldEnableDetailPageNavigation
>
{shouldShowMarkAsCashButton && !shouldUseNarrowLayout && (
<Button
success
text={translate('iou.markAsCash')}
style={[styles.p0]}
onPress={markAsCash}
/>
)}
{isDuplicate && !shouldUseNarrowLayout && (
<Button
success
text={translate('iou.reviewDuplicates')}
style={[styles.p0, styles.ml2]}
onPress={() => {
if (!reportID) {
return;
}
Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(reportID, Navigation.getReportRHPActiveRoute()));
}}
/>
{!shouldUseNarrowLayout && (
<View style={[styles.flexRow, styles.gap2]}>
{!!primaryAction && primaryActionImplementation[primaryAction]}
{!!applicableSecondaryActions.length && (
<ButtonWithDropdownMenu
success={false}
onPress={() => {}}
shouldAlwaysShowDropdownMenu
customText={translate('common.more')}
options={applicableSecondaryActions}
isSplitButton={false}
/>
)}
</View>
)}
{shouldDisplayTransactionNavigation && <MoneyRequestReportTransactionsNavigation currentReportID={reportID} />}
</HeaderWithBackButton>
{shouldShowMarkAsCashButton && shouldUseNarrowLayout && (
<View style={[styles.ph5, styles.pb3]}>
<Button
success
text={translate('iou.markAsCash')}
style={[styles.w100, styles.pr0]}
onPress={markAsCash}
/>
</View>
)}
{isDuplicate && shouldUseNarrowLayout && (
<View style={[styles.ph5, styles.pb3]}>
<Button
success
text={translate('iou.reviewDuplicates')}
style={[styles.w100, styles.pr0]}
onPress={() => {
if (!reportID) {
return;
}
Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(reportID, Navigation.getReportRHPActiveRoute()));
}}
/>
{shouldUseNarrowLayout && (
<View style={[styles.flexRow, styles.gap2, styles.pb3, styles.ph5, styles.w100, styles.alignItemsCenter, styles.justifyContentCenter]}>
{!!primaryAction && <View style={[styles.flexGrow4]}>{primaryActionImplementation[primaryAction]}</View>}
{!!applicableSecondaryActions.length && (
<ButtonWithDropdownMenu
success={false}
onPress={() => {}}
shouldAlwaysShowDropdownMenu
customText={translate('common.more')}
options={applicableSecondaryActions}
isSplitButton={false}
wrapperStyle={[!primaryAction && styles.flexGrow4]}
/>
)}
</View>
)}
{!!statusBarProps && (
Expand All @@ -222,6 +294,36 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
</View>
)}
<LoadingBar shouldShow={(isLoadingReportData && shouldUseNarrowLayout) ?? false} />
<DecisionModal
title={translate('common.downloadFailedTitle')}
prompt={translate('common.downloadFailedDescription')}
isSmallScreenWidth={isSmallScreenWidth}
onSecondOptionSubmit={() => setDownloadErrorModalVisible(false)}
secondOptionText={translate('common.buttonConfirm')}
isVisible={downloadErrorModalVisible}
onClose={() => setDownloadErrorModalVisible(false)}
/>
<ConfirmModal
title={translate('iou.deleteExpense', {count: 1})}
isVisible={isDeleteModalVisible}
onConfirm={() => {
setIsDeleteModalVisible(false);
if (!parentReportAction || !transaction) {
throw new Error('Data missing');
}

deleteMoneyRequest(transaction?.transactionID, parentReportAction);

const goBackRoute = getNavigationUrlOnMoneyRequestDelete(transaction.transactionID, parentReportAction, true);
navigateBackOnDeleteTransaction(goBackRoute);
Comment on lines +317 to +318
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have just called the onBackButtonPress function here. This redirection logic caused #62075 later on.

}}
onCancel={() => setIsDeleteModalVisible(false)}
prompt={translate('iou.deleteConfirmation', {count: 1})}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
danger
shouldEnableNewFocusManagement
/>
</View>
);
}
Expand Down
Loading