Skip to content

Commit

Permalink
fix LHN last message text preview
Browse files Browse the repository at this point in the history
  • Loading branch information
getusha committed Nov 28, 2023
1 parent 30f43e4 commit 2bbd0ef
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyRequestPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function MoneyRequestPreview(props) {
const isDistanceRequest = TransactionUtils.isDistanceRequest(props.transaction);
const isExpensifyCardTransaction = TransactionUtils.isExpensifyCardTransaction(props.transaction);
const isSettled = ReportUtils.isSettled(props.iouReport.reportID);
const isCancelled = ReportActionsUtils.isReimbursementDeQueuedAction(props.iouReport.reportID);
const isCancelled = ReportActionsUtils.isReimbursementDeQueued(props.iouReport.reportID);
const isDeleted = lodashGet(props.action, 'pendingAction', null) === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;

// Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyRequestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor

// Flags for allowing or disallowing editing a money request
const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID);
const isCancelled = ReportActionsUtils.isReimbursementDeQueuedAction(moneyRequestReport.reportID);
const isCancelled = ReportActionsUtils.isReimbursementDeQueued(moneyRequestReport.reportID);
const canEdit = ReportUtils.canEditMoneyRequest(parentReportAction);
const canEditAmount = canEdit && !isSettled && !isCardTransaction;

Expand Down
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ function getLastMessageTextForReport(report) {
lastMessageTextFromReport = ReportUtils.getReportPreviewMessage(iouReport, lastIOUMoneyReport, true, ReportUtils.isChatReport(report));
} else if (ReportActionUtils.isReimbursementQueuedAction(lastReportAction)) {
lastMessageTextFromReport = ReportUtils.getReimbursementQueuedActionMessage(lastReportAction, report);
} else if (ReportActionUtils.isReimbursementDeQueuedAction(lastReportAction)) {
lastMessageTextFromReport = ReportUtils.getReimbursementDeQueuedActionMessage(report);
} else if (ReportActionUtils.isDeletedParentAction(lastReportAction) && ReportUtils.isChatReport(report)) {
lastMessageTextFromReport = ReportUtils.getDeletedParentActionMessageForChatReport(lastReportAction);
} else if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml, translationKey: report.lastMessageTranslationKey})) {
Expand Down
10 changes: 9 additions & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ function isChannelLogMemberAction(reportAction: OnyxEntry<ReportAction>) {
);
}

function isReimbursementDeQueuedAction(reportID: string): boolean {
/**
* Returns whether the report is dequeued only using reportID
*/
function isReimbursementDeQueued(reportID: string): boolean {
if (!allReportActions) {
return false;
}
Expand All @@ -118,6 +121,10 @@ function isReimbursementDeQueuedAction(reportID: string): boolean {
return reportAction.some((action) => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED);
}

function isReimbursementDeQueuedAction(reportAction: OnyxEntry<ReportAction>): boolean {
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED;
}

/**
* Returns whether the comment is a thread parent message/the first message in a thread
*/
Expand Down Expand Up @@ -707,6 +714,7 @@ export {
hasRequestFromCurrentAccount,
getFirstVisibleReportActionID,
isChannelLogMemberAction,
isReimbursementDeQueued,
isReimbursementDeQueuedAction,
};

Expand Down
13 changes: 12 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,16 @@ function getReimbursementQueuedActionMessage(reportAction: OnyxEntry<ReportActio
return Localize.translateLocal(messageKey, {submitterDisplayName});
}

/**
* Returns the preview message for `REIMBURSEMENTDEQUEUED` action
*/
function getReimbursementDeQueuedActionMessage(report: OnyxEntry<Report>): string {
const submitterDisplayName = getDisplayNameForParticipant(report?.ownerAccountID, true) ?? '';
const amount = CurrencyUtils.convertToDisplayString(report?.total ?? 0, report?.currency);

return Localize.translateLocal('iou.canceledRequest', {submitterDisplayName, amount});
}

/**
* Returns the last visible message for a given report after considering the given optimistic actions
*
Expand Down Expand Up @@ -1684,7 +1694,7 @@ function getMoneyRequestReportName(report: OnyxEntry<Report>, policy: OnyxEntry<
return `${payerPaidAmountMessage}${Localize.translateLocal('iou.pending')}`;
}

if (report?.reportID && ReportActionsUtils.isReimbursementDeQueuedAction(report.reportID)) {
if (report?.reportID && ReportActionsUtils.isReimbursementDeQueued(report.reportID)) {
return `${payerPaidAmountMessage}${Localize.translateLocal('iou.canceled')}`;
}

Expand Down Expand Up @@ -4380,6 +4390,7 @@ export {
shouldUseFullTitleToDisplay,
parseReportRouteParams,
getReimbursementQueuedActionMessage,
getReimbursementDeQueuedActionMessage,
getPersonalDetailsForAccountID,
getChannelLogMemberMessage,
getRoom,
Expand Down

0 comments on commit 2bbd0ef

Please sign in to comment.