Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a9129f2
fix: Content before dot separator is empty
daledah Apr 14, 2025
54007dc
fix test
daledah Apr 14, 2025
2ff1b21
fix jest test 3
daledah Apr 14, 2025
9f31abe
Merge branch 'main' into fix/60087
daledah Apr 17, 2025
2b8c76d
add the optimistic to delete money request
daledah Apr 17, 2025
07ab38e
fix ts error
daledah Apr 17, 2025
b6a061e
Merge branch 'main' into fix/60087
daledah Apr 18, 2025
2ed6d5e
Merge branch 'main' into fix/60087
daledah Apr 18, 2025
5a048ca
fix test
daledah Apr 18, 2025
f083498
fix: show deleted transactions and fix test
daledah Apr 19, 2025
5c64865
fix: add canBeMissing
daledah Apr 19, 2025
6342dc0
fix: prettier
daledah Apr 19, 2025
f2286bf
Merge branch 'main' into fix/60087
daledah Apr 21, 2025
a3e3688
fix: lint
daledah Apr 21, 2025
b0cf488
Merge branch 'main' into fix/60087
daledah Apr 22, 2025
84d6c99
fix: lint
daledah Apr 22, 2025
be1d152
revert latest changes
daledah Apr 23, 2025
b071954
Merge branch 'main' into fix/60087
daledah Apr 23, 2025
bb6bd47
fix test
daledah Apr 23, 2025
f6134e8
fix canBeMissing
daledah Apr 24, 2025
0a09abc
Merge branch 'main' into fix/60087
daledah Apr 25, 2025
b9dd6ca
Merge branch 'main' into fix/60087
daledah Apr 28, 2025
64f3692
add pending delete action for deleted transaction
daledah Apr 28, 2025
59a3d60
fix: apply strikethrough style for delete action
daledah Apr 29, 2025
50792cb
Merge branch 'main' into fix/60087
daledah May 2, 2025
51a07aa
fix: show not-allowed cursor for pending delete report preview
daledah May 2, 2025
598870d
fix: incorrect currency when delete report
daledah May 2, 2025
d263e68
Merge branch 'main' into fix/60087
daledah May 7, 2025
3caf674
fix: apply suggestions
daledah May 7, 2025
523ba62
Merge branch 'main' into fix/60087
daledah May 8, 2025
a2ac4f5
Merge branch 'main' into fix/60087
daledah May 8, 2025
335d091
Merge branch 'main' into fix/60087
daledah May 9, 2025
259fa42
Merge branch 'main' into fix/60087
daledah May 9, 2025
359450f
fix: add missing styles
daledah May 9, 2025
ac8b346
Merge branch 'main' into fix/60087
daledah May 9, 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
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ function MoneyRequestReportPreviewContent({
return getReportPreviewAction(violations, iouReport, policy, transactions, isIouReportArchived, reportActions);
}, [isPaidAnimationRunning, violations, iouReport, policy, transactions, isIouReportArchived, reportActions]);

const isReportDeleted = action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;

const reportPreviewActions = {
[CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT]: (
<Button
Expand Down Expand Up @@ -582,7 +584,7 @@ function MoneyRequestReportPreviewContent({
needsOffscreenAlphaCompositing
style={styles.mt1}
>
<View style={[styles.chatItemMessage, containerStyles]}>
<View style={[styles.chatItemMessage, isReportDeleted && [styles.cursorDisabled, styles.pointerEventsAuto], containerStyles]}>
<PressableWithoutFeedback
onPress={onPress}
onPressIn={() => canUseTouchScreen() && ControlSelection.block()}
Expand All @@ -599,6 +601,7 @@ function MoneyRequestReportPreviewContent({
styles.justifyContentBetween,
StyleUtils.getBackgroundColorStyle(theme.cardBG),
shouldShowBorder ? styles.borderedContentCardLarge : styles.reportContainerBorderRadius,
isReportDeleted && styles.pointerEventsNone,
]}
role={getButtonRole(true)}
isNested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function TransactionPreviewContent({
? getIOUData(managerID, ownerAccountID, isIOUReport(iouReport) || reportPreviewAction?.childType === CONST.REPORT.TYPE.IOU, personalDetails, requestAmount ?? 0)
: undefined;
const {from, to} = iouData ?? {from: null, to: null};
const isDeleted = action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
const isDeleted = action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
const shouldShowCategoryOrTag = shouldShowCategory || shouldShowTag;
const shouldShowMerchantOrDescription = shouldShowDescription || shouldShowMerchant;
const shouldShowIOUHeader = !!from && !!to;
Expand Down Expand Up @@ -172,15 +172,13 @@ function TransactionPreviewContent({
shouldHideOnDelete={shouldHideOnDelete}
>
<View style={[(isScanning || isWhisper) && [styles.reportPreviewBoxHoverBorder, styles.reportContainerBorderRadius]]}>
{!isDeleted && (
<ReportActionItemImages
images={receiptImages}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
isHovered={isHovered || isScanning}
size={1}
shouldUseAspectRatio
/>
)}
<ReportActionItemImages
images={receiptImages}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
isHovered={isHovered || isScanning}
size={1}
shouldUseAspectRatio
/>
{shouldShowSkeleton ? (
<TransactionPreviewSkeletonView transactionPreviewWidth={transactionPreviewWidth} />
) : (
Expand All @@ -202,7 +200,7 @@ function TransactionPreviewContent({
)}
<View style={previewTextViewGap}>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<Text style={[styles.textLabelSupporting, styles.flex1, styles.lh16, previewTextMargin]}>{previewHeaderText}</Text>
<Text style={[isDeleted && styles.lineThrough, styles.textLabelSupporting, styles.flex1, styles.lh16, previewTextMargin]}>{previewHeaderText}</Text>
{isBillSplit && (
<View style={styles.moneyRequestPreviewBoxAvatar}>
<MultipleAvatars
Expand Down Expand Up @@ -256,7 +254,7 @@ function TransactionPreviewContent({
</View>
<View style={[styles.flexRow, styles.justifyContentEnd]}>
{!!splitShare && (
<Text style={[styles.textLabel, styles.colorMuted, styles.amountSplitPadding]}>
<Text style={[isDeleted && styles.lineThrough, styles.textLabel, styles.colorMuted, styles.amountSplitPadding]}>
{translate('iou.yourSplit', {amount: convertToDisplayString(splitShare, requestCurrency)})}
</Text>
)}
Expand All @@ -283,7 +281,7 @@ function TransactionPreviewContent({
/>
<Text
numberOfLines={1}
style={[styles.textMicroSupporting, styles.pre, styles.flexShrink1]}
style={[isDeleted && styles.lineThrough, styles.textMicroSupporting, styles.pre, styles.flexShrink1]}
>
{category}
</Text>
Expand All @@ -299,7 +297,7 @@ function TransactionPreviewContent({
/>
<Text
numberOfLines={1}
style={[styles.textMicroSupporting, styles.pre, styles.flexShrink1]}
style={[isDeleted && styles.lineThrough, styles.textMicroSupporting, styles.pre, styles.flexShrink1]}
>
{getCleanedTagName(tag)}
</Text>
Expand All @@ -318,7 +316,7 @@ function TransactionPreviewContent({
/>
<Text
numberOfLines={1}
style={[styles.textMicroSupporting, styles.pre, styles.flexShrink1, {color: theme.danger}]}
style={[isDeleted && styles.lineThrough, styles.textMicroSupporting, styles.pre, styles.flexShrink1, {color: theme.danger}]}
>
{RBRMessage}
</Text>
Expand Down
3 changes: 3 additions & 0 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ function isAmountMissing(transaction: OnyxEntry<Transaction>) {
}

function isCreatedMissing(transaction: OnyxEntry<Transaction>) {
if (!transaction) {
return true;
}
return transaction?.created === '' && (!transaction.created || transaction.modifiedCreated === '');
}

Expand Down
20 changes: 13 additions & 7 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7093,7 +7093,7 @@ function updateMoneyRequestAmountAndCurrency({
* @param reportAction - The reportAction of the transaction in the IOU report
* @return the url to navigate back once the money request is deleted
*/
function prepareToCleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction) {
function prepareToCleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, shouldKeepIOUTransactionID = false) {
// STEP 1: Get all collections we're updating
const iouReportID = isMoneyRequestAction(reportAction) ? getOriginalMessage(reportAction)?.IOUReportID : undefined;
const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`] ?? null;
Expand Down Expand Up @@ -7129,7 +7129,7 @@ function prepareToCleanUpMoneyRequest(transactionID: string, reportAction: OnyxT
},
],
originalMessage: {
IOUTransactionID: null,
IOUTransactionID: shouldKeepIOUTransactionID ? transactionID : null,
},
errors: null,
},
Expand Down Expand Up @@ -7309,7 +7309,7 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo
chatReport,
iouReport,
reportPreviewAction,
} = prepareToCleanUpMoneyRequest(transactionID, reportAction);
} = prepareToCleanUpMoneyRequest(transactionID, reportAction, Permissions.canUseTableReportView(betas));

const urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete(transactionID, reportAction, isSingleTransactionView);
// build Onyx data
Expand Down Expand Up @@ -7456,7 +7456,7 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo
* @param isSingleTransactionView - whether we are in the transaction thread report
* @return the url to navigate back once the money request is deleted
*/
function deleteMoneyRequest(transactionID: string | undefined, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false) {
function deleteMoneyRequest(transactionID: string | undefined, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false, shouldRemoveIOUTransactionID = true) {
if (!transactionID) {
return;
}
Expand All @@ -7475,7 +7475,7 @@ function deleteMoneyRequest(transactionID: string | undefined, reportAction: Ony
transactionViolations,
iouReport,
reportPreviewAction,
} = prepareToCleanUpMoneyRequest(transactionID, reportAction);
} = prepareToCleanUpMoneyRequest(transactionID, reportAction, shouldRemoveIOUTransactionID);

const urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete(transactionID, reportAction, isSingleTransactionView);

Expand All @@ -7485,7 +7485,7 @@ function deleteMoneyRequest(transactionID: string | undefined, reportAction: Ony
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: null,
value: {...transaction, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE},
},
];

Expand All @@ -7499,7 +7499,7 @@ function deleteMoneyRequest(transactionID: string | undefined, reportAction: Ony
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: transaction ?? null,
value: {...transaction, pendingAction: null},
},
];

Expand Down Expand Up @@ -7690,6 +7690,12 @@ function deleteMoneyRequest(transactionID: string | undefined, reportAction: Ony
});
}

successData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: null,
});

failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ function PureReportActionItem({
);
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && isClosedExpenseReportWithNoExpenses) {
children = <RenderHTML html={`<deleted-action>${translate('parentReportAction.deletedReport')}</deleted-action>`} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && canUseTableReportView && action.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && canUseTableReportView) {
children = (
<MoneyRequestReportPreview
iouReportID={getIOUReportIDFromReportActionPreview(action)}
Expand Down
3 changes: 2 additions & 1 deletion tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3143,7 +3143,8 @@ describe('actions/IOU', () => {
});
});

expect(t).toBeFalsy();
expect(t).toBeTruthy();
Comment thread
daledah marked this conversation as resolved.
expect(t?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);

// Given fetch operations are resumed
mockFetch?.resume?.();
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/TransactionPreviewUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('TransactionPreviewUtils', () => {
const functionArgs = {...basicProps, iouReport: undefined, transaction: undefined};
const result = getTransactionPreviewTextAndTranslationPaths(functionArgs);
expect(result.RBRMessage.text).toEqual('');
expect(result.previewHeaderText).toContainEqual({text: ''});
expect(result.previewHeaderText).toContainEqual({translationPath: 'iou.cash'});
expect(result.displayAmountText.text).toEqual('$0.00');
});

Expand Down