Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Stop using reportAction.originalMessage or reportAction.messge #40168

Merged
merged 62 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
a9fedf4
feture: Stop using reportAction.originalMessage or reportAction.messa…
nkdengineer Apr 12, 2024
9c9cd84
refactor using getReportActionMessage
nkdengineer Apr 13, 2024
23b45eb
revert change originalMessage
nkdengineer May 8, 2024
342f51f
fix ts check
nkdengineer May 8, 2024
f1e1de8
merge main
nkdengineer May 14, 2024
68d4bda
merge main
nkdengineer May 16, 2024
226aede
Merge branch 'main' into fix/39797
nkdengineer May 16, 2024
40371ab
Merge branch 'main' into fix/39797
nkdengineer May 20, 2024
720a3d6
merge main
nkdengineer May 27, 2024
11961e4
start removing originalMessage
nkdengineer May 27, 2024
04d072e
fix lint
nkdengineer May 27, 2024
de34018
remove originalMessage in ReportActionsUtils
nkdengineer May 27, 2024
ba85808
remove originalMessage in ReportUtils
nkdengineer May 27, 2024
e22f5de
remove originalMessage in ReportActionItem
nkdengineer May 27, 2024
6a8c37a
remove originalMessage in IOU, Report, Policy lib
nkdengineer May 27, 2024
28ead5b
revert unecessary change
nkdengineer May 27, 2024
c53630b
remove originalMessage in ReportActionItem
nkdengineer May 27, 2024
48d26c5
fix test
nkdengineer May 27, 2024
78efa96
fix test
nkdengineer May 27, 2024
ddeabfc
remove originalMessage in other files
nkdengineer May 27, 2024
8e3271b
merge main
nkdengineer May 28, 2024
ff08fe1
remove originalMessage in MoneyRequestHeader
nkdengineer May 28, 2024
5758323
merge main
nkdengineer May 29, 2024
797f46c
merge main
nkdengineer Jun 3, 2024
c966d0e
refactor type of originalMessage
nkdengineer Jun 3, 2024
4ef5d61
resolve with getOriginalMessage function
nkdengineer Jun 4, 2024
0f37a8b
merge main
nkdengineer Jun 4, 2024
573e5d4
fix type error
nkdengineer Jun 4, 2024
3d59b1a
fix type
nkdengineer Jun 4, 2024
8fb20ac
complete type check
nkdengineer Jun 4, 2024
2c7649f
remove unnecessary type
nkdengineer Jun 4, 2024
85f876f
fix ts check
nkdengineer Jun 4, 2024
dc26e46
fix lint
nkdengineer Jun 4, 2024
d489a95
add JSDoc for deprecated field
nkdengineer Jun 4, 2024
2d492de
merge main
nkdengineer Jun 5, 2024
10f1972
fix logic
nkdengineer Jun 5, 2024
622b7c8
fix lint
nkdengineer Jun 5, 2024
602388e
use isActionOfType
nkdengineer Jun 5, 2024
5808acd
clean code
nkdengineer Jun 5, 2024
a7e3f34
replace text to html
nkdengineer Jun 5, 2024
f70e9b7
replace text to html
nkdengineer Jun 5, 2024
201f875
revert unnecessary change
nkdengineer Jun 5, 2024
10631d5
fix lint
nkdengineer Jun 5, 2024
9449ca0
merge main
nkdengineer Jun 7, 2024
a31f9a0
fix ts check
nkdengineer Jun 7, 2024
8a0cf61
merge main
nkdengineer Jun 10, 2024
77c17f6
Merge branch 'main' into fix/39797
nkdengineer Jun 12, 2024
9e9d0ee
fix ts check
nkdengineer Jun 12, 2024
294df4a
update type
nkdengineer Jun 12, 2024
372e00d
fix lint
nkdengineer Jun 12, 2024
a53dfe2
merge main
nkdengineer Jun 13, 2024
c0dab4a
Merge branch 'main' into fix/39797
nkdengineer Jun 13, 2024
85ca4dc
fix lint
nkdengineer Jun 13, 2024
b785353
merge main
nkdengineer Jun 14, 2024
a1908d8
fix lint
nkdengineer Jun 14, 2024
257edf4
merge main
nkdengineer Jun 17, 2024
fb7d604
merge main
nkdengineer Jun 17, 2024
87610d6
Merge branch 'main' into fix/39797
nkdengineer Jun 18, 2024
4b5a4c5
merge main
nkdengineer Jun 20, 2024
6b5466e
remove unused type
nkdengineer Jun 20, 2024
839df17
fix lint
nkdengineer Jun 20, 2024
1f7c785
merge main
nkdengineer Jun 21, 2024
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: 1 addition & 1 deletion src/components/ArchivedReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function ArchivedReportFooter({report, reportClosedAction, personalDetails = {}}
const styles = useThemeStyles();
const {translate} = useLocalize();

const originalMessage = reportClosedAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED ? reportClosedAction.originalMessage : null;
const originalMessage = ReportActionsUtils.isClosedAction(reportClosedAction) ? ReportActionsUtils.getOriginalMessage(reportClosedAction) : null;
const archiveReason = originalMessage?.reason ?? CONST.REPORT.ARCHIVE_REASON.DEFAULT;
const actorPersonalDetails = personalDetails?.[reportClosedAction?.actorAccountID ?? -1];
let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(actorPersonalDetails);
Expand Down
2 changes: 1 addition & 1 deletion src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ export default withOnyx<AttachmentModalProps, AttachmentModalOnyxProps>({
transaction: {
key: ({report}) => {
const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1');
const transactionID = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction?.originalMessage.IOUTransactionID ?? '-1' : '-1';
const transactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID ?? '-1' : '-1';
return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ function extractAttachments(
return;
}

const decision = action?.message?.[0]?.moderationDecision?.decision;
const decision = ReportActionsUtils.getReportActionMessage(action)?.moderationDecision?.decision;
const hasBeenFlagged = decision === CONST.MODERATION.MODERATOR_DECISION_PENDING_HIDE || decision === CONST.MODERATION.MODERATOR_DECISION_HIDDEN;
const html = (action?.message?.[0]?.html ?? '').replace('/>', `data-flagged="${hasBeenFlagged}" data-id="${action.reportActionID}"/>`);
const html = ReportActionsUtils.getReportActionHtml(action).replace('/>', `data-flagged="${hasBeenFlagged}" data-id="${action.reportActionID}"/>`);
htmlParser.write(html);
});
htmlParser.end();
Expand Down
8 changes: 5 additions & 3 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
const itemParentReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${itemFullReport?.parentReportID}`];
const itemParentReportAction = itemParentReportActions?.[itemFullReport?.parentReportActionID ?? '-1'];
const itemPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${itemFullReport?.policyID}`];
const transactionID = itemParentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? itemParentReportAction.originalMessage.IOUTransactionID ?? '-1' : '-1';
const transactionID = ReportActionsUtils.isMoneyRequestAction(itemParentReportAction)
? ReportActionsUtils.getOriginalMessage(itemParentReportAction)?.IOUTransactionID ?? '-1'
: '-1';
const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
const hasDraftComment = DraftCommentUtils.isValidDraftComment(draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`]);
const sortedReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(itemReportActions);
Expand All @@ -128,8 +130,8 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
// Get the transaction for the last report action
let lastReportActionTransactionID = '';

if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) {
lastReportActionTransactionID = lastReportAction.originalMessage?.IOUTransactionID ?? '-1';
if (ReportActionsUtils.isMoneyRequestAction(lastReportAction)) {
lastReportActionTransactionID = ReportActionsUtils.getOriginalMessage(lastReportAction)?.IOUTransactionID ?? '-1';
}
const lastReportActionTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${lastReportActionTransactionID}`] ?? {};

Expand Down
12 changes: 8 additions & 4 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
if (!reportActions || !transactionThreadReport?.parentReportActionID) {
return null;
}
return reportActions.find((action) => action.reportActionID === transactionThreadReport.parentReportActionID);
return reportActions.find((action): action is OnyxTypes.ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU> => action.reportActionID === transactionThreadReport.parentReportActionID);
}, [reportActions, transactionThreadReport?.parentReportActionID]);
const isDeletedParentAction = ReportActionsUtils.isDeletedAction(requestParentReportAction as OnyxTypes.ReportAction);
const isDeletedParentAction = !!requestParentReportAction && ReportActionsUtils.isDeletedAction(requestParentReportAction);

// Only the requestor can delete the request, admins can only edit it.
const isActionOwner =
Expand Down Expand Up @@ -151,7 +151,9 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea

const deleteTransaction = useCallback(() => {
if (requestParentReportAction) {
const iouTransactionID = requestParentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? requestParentReportAction.originalMessage?.IOUTransactionID ?? '-1' : '-1';
const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(requestParentReportAction)
? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? '-1'
: '-1';
if (ReportActionsUtils.isTrackExpenseAction(requestParentReportAction)) {
navigateBackToAfterDelete.current = IOU.deleteTrackExpense(moneyRequestReport?.reportID ?? '-1', iouTransactionID, requestParentReportAction, true);
} else {
Expand All @@ -166,7 +168,9 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
if (!requestParentReportAction) {
return;
}
const iouTransactionID = requestParentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? requestParentReportAction.originalMessage?.IOUTransactionID ?? '-1' : '-1';
const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(requestParentReportAction)
? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? '-1'
: '-1';
const reportID = transactionThreadReport?.reportID ?? '-1';

TransactionActions.markAsCash(iouTransactionID, reportID);
Expand Down
11 changes: 7 additions & 4 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Route} from '@src/ROUTES';
import type {Policy, Report, ReportAction} from '@src/types/onyx';
import type {OriginalMessageIOU} from '@src/types/onyx/OriginalMessage';
import type IconAsset from '@src/types/utils/IconAsset';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
import Button from './Button';
Expand Down Expand Up @@ -51,7 +50,11 @@ type MoneyRequestHeaderProps = {

function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrowLayout = false, onBackButtonPress}: MoneyRequestHeaderProps) {
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`);
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${(parentReportAction as ReportAction & OriginalMessageIOU)?.originalMessage?.IOUTransactionID ?? -1}`);
const [transaction] = useOnyx(
`${ONYXKEYS.COLLECTION.TRANSACTION}${
ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID ?? -1 : -1
}`,
);
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [session] = useOnyx(ONYXKEYS.SESSION);
const [dismissedHoldUseExplanation, dismissedHoldUseExplanationResult] = useOnyx(ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, {initialValue: true});
Expand Down Expand Up @@ -80,7 +83,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow

const deleteTransaction = useCallback(() => {
if (parentReportAction) {
const iouTransactionID = parentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage?.IOUTransactionID ?? '-1' : '-1';
const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID ?? '-1' : '-1';
if (ReportActionsUtils.isTrackExpenseAction(parentReportAction)) {
navigateBackToAfterDelete.current = IOU.deleteTrackExpense(parentReport?.reportID ?? '-1', iouTransactionID, parentReportAction, true);
} else {
Expand All @@ -104,7 +107,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow
const canDeleteRequest = isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || ReportUtils.isTrackExpenseReport(report)) && !isDeletedParentAction;

const changeMoneyRequestStatus = () => {
const iouTransactionID = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage?.IOUTransactionID ?? '-1' : '-1';
const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID ?? '-1' : '-1';

if (isOnHold) {
IOU.unholdRequest(iouTransactionID, report?.reportID);
Expand Down
9 changes: 5 additions & 4 deletions src/components/ReportActionItem/ChronosOOOListActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import DateUtils from '@libs/DateUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as Chronos from '@userActions/Chronos';
import type {OriginalMessageChronosOOOList} from '@src/types/onyx/OriginalMessage';
import type {ReportActionBase} from '@src/types/onyx/ReportAction';
import type CONST from '@src/CONST';
import type ReportAction from '@src/types/onyx/ReportAction';

type ChronosOOOListActionsProps = {
/** The ID of the report */
reportID: string;

/** All the data of the action */
action: ReportActionBase & OriginalMessageChronosOOOList;
action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.CHRONOS_OOO_LIST>;
};

function ChronosOOOListActions({reportID, action}: ChronosOOOListActionsProps) {
const styles = useThemeStyles();

const {translate, preferredLocale} = useLocalize();

const events = action.originalMessage?.events ?? [];
const events = ReportActionsUtils.getOriginalMessage(action)?.events ?? [];

if (!events.length) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import variables from '@styles/variables';
import * as PaymentMethods from '@userActions/PaymentMethods';
import * as Report from '@userActions/Report';
import CONST from '@src/CONST';
import type {IOUMessage} from '@src/types/onyx/OriginalMessage';
import type {OriginalMessageIOU} from '@src/types/onyx/OriginalMessage';
import type {EmptyObject} from '@src/types/utils/EmptyObject';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type {MoneyRequestPreviewProps, PendingMessageProps} from './types';
Expand Down Expand Up @@ -74,7 +74,8 @@ function MoneyRequestPreviewContent({
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport);
const {canUseViolations} = usePermissions();

const participantAccountIDs = action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && isBillSplit ? action.originalMessage.participantAccountIDs ?? [] : [managerID, ownerAccountID];
const participantAccountIDs =
ReportActionsUtils.isMoneyRequestAction(action) && isBillSplit ? ReportActionsUtils.getOriginalMessage(action)?.participantAccountIDs ?? [] : [managerID, ownerAccountID];
const participantAvatars = OptionsListUtils.getAvatarsForAccountIDs(participantAccountIDs, personalDetails ?? {});
const sortedParticipantAvatars = lodashSortBy(participantAvatars, (avatar) => avatar.id);
if (isPolicyExpenseChat && isBillSplit) {
Expand Down Expand Up @@ -225,7 +226,7 @@ function MoneyRequestPreviewContent({
};

const getDisplayDeleteAmountText = (): string => {
const iouOriginalMessage: IOUMessage | EmptyObject = action?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? action.originalMessage : {};
const iouOriginalMessage: OriginalMessageIOU | EmptyObject = ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action) ?? {} : {};
const {amount = 0, currency = CONST.CURRENCY.USD} = iouOriginalMessage;

return CurrencyUtils.convertToDisplayString(amount, currency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default withOnyx<MoneyRequestPreviewProps, MoneyRequestPreviewOnyxProps>(
transaction: {
key: ({action}) => {
const isMoneyRequestAction = ReportActionsUtils.isMoneyRequestAction(action);
const transactionID = isMoneyRequestAction ? action?.originalMessage?.IOUTransactionID : 0;
const transactionID = isMoneyRequestAction ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID : 0;
return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`;
},
},
Expand Down
8 changes: 5 additions & 3 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function MoneyRequestView({
const isCancelled = moneyRequestReport && moneyRequestReport.isCancelledIOU;

// Used for non-restricted fields such as: description, category, tag, billable, etc.
const canEdit = ReportUtils.canEditMoneyRequest(parentReportAction);
const canEdit = ReportActionsUtils.isMoneyRequestAction(parentReportAction) && ReportUtils.canEditMoneyRequest(parentReportAction);
const canEditTaxFields = canEdit && !isDistanceRequest;

const canEditAmount = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.AMOUNT);
Expand Down Expand Up @@ -614,15 +614,17 @@ export default withOnyx<MoneyRequestViewPropsWithoutTransaction, MoneyRequestVie
transaction: {
key: ({report, parentReportActions}) => {
const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '-1'];
const originalMessage = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage : undefined;
const originalMessage =
parentReportAction && ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction) : undefined;
const transactionID = originalMessage?.IOUTransactionID ?? -1;
return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`;
},
},
transactionViolations: {
key: ({report, parentReportActions}) => {
const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '-1'];
const originalMessage = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage : undefined;
const originalMessage =
parentReportAction && ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction) : undefined;
const transactionID = originalMessage?.IOUTransactionID ?? -1;
return `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`;
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/RenameAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalD
import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import type {ReportAction} from '@src/types/onyx';

type RenameActionProps = WithCurrentUserPersonalDetailsProps & {
Expand All @@ -20,7 +20,7 @@ function RenameAction({currentUserPersonalDetails, action}: RenameActionProps) {
const userDisplayName = action.person?.[0]?.text;
const actorAccountID = action.actorAccountID ?? '-1';
const displayName = actorAccountID === currentUserAccountID ? `${translate('common.you')}` : `${userDisplayName}`;
const originalMessage = action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED ? action.originalMessage : null;
const originalMessage = ReportActionsUtils.isRenamedAction(action) ? ReportActionsUtils.getOriginalMessage(action) : null;
const oldName = originalMessage?.oldName ?? '';
const newName = originalMessage?.newName ?? '';

Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import * as CurrencyUtils from '@libs/CurrencyUtils';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import Navigation from '@libs/Navigation/Navigation';
import * as ReceiptUtils from '@libs/ReceiptUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import StringUtils from '@libs/StringUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
Expand Down Expand Up @@ -214,7 +215,7 @@ function ReportPreview({

// If iouReport is not available, get amount from the action message (Ex: "Domain20821's Workspace owes $33.00" or "paid ₫60" or "paid -₫60 elsewhere")
let displayAmount = '';
const actionMessage = action.message?.[0]?.text ?? '';
const actionMessage = ReportActionsUtils.getReportActionText(action);
const splits = actionMessage.split(' ');

splits.forEach((split) => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/ReportActionItem/TripRoomPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as CurrencyUtils from '@libs/CurrencyUtils';
import DateUtils from '@libs/DateUtils';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import Navigation from '@libs/Navigation/Navigation';
import {getReportActionText} from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as TripReservationUtils from '@libs/TripReservationUtils';
import type {ContextMenuAnchor} from '@pages/home/report/ContextMenu/ReportActionContextMenu';
Expand Down Expand Up @@ -123,7 +124,7 @@ function TripRoomPreview({action, chatReportID, containerStyles, contextMenuAnch

// If iouReport is not available, get amount from the action message (Ex: "Domain20821's Workspace owes $33.00" or "paid ₫60" or "paid -₫60 elsewhere")
let displayAmountValue = '';
const actionMessage = action.message?.[0]?.text ?? '';
const actionMessage = getReportActionText(action) ?? '';
const splits = actionMessage.split(' ');

splits.forEach((split) => {
Expand All @@ -135,7 +136,7 @@ function TripRoomPreview({action, chatReportID, containerStyles, contextMenuAnch
});

return displayAmountValue;
}, [action.message, iouReport?.currency, totalDisplaySpend]);
}, [action, iouReport?.currency, totalDisplaySpend]);

return (
<OfflineWithFeedback
Expand Down
Loading
Loading