Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion src/components/LHNOptionsList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ type OptionRowLHNDataProps = {
/** Array of report actions for this report */
reportActions: OnyxEntry<ReportActions>;

/** Array of report actions of IOU report related to this report last action */
/**
* Array of report actions for the IOU report related to the last action of this report.
* If the last action is a report action preview, the last message of the report depends on
* the report actions of the IOU report linked to the report action preview.
* Changes in the IOU report report actions will affect the last message of this report.
*/
iouReportReportActions: OnyxEntry<ReportActions>;

/** List of transaction violation */
Expand Down
10 changes: 5 additions & 5 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ Onyx.connect({
const lastReportActions: ReportActions = {};
const allSortedReportActions: Record<string, ReportAction[]> = {};
let allReportActions: OnyxCollection<ReportActions>;
const visibleReportActionItems: ReportActions = {};
const lastVisibleReportActions: ReportActions = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
Expand Down Expand Up @@ -327,7 +327,7 @@ Onyx.connect({
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
!ReportActionUtils.isResolvedActionTrackExpense(reportAction),
);
visibleReportActionItems[reportID] = reportActionsForDisplay[0];
lastVisibleReportActions[reportID] = reportActionsForDisplay[0];
});
},
});
Expand Down Expand Up @@ -669,7 +669,7 @@ function getIOUReportIDOfLastAction(report: OnyxEntry<Report>): string | undefin
if (!report?.reportID) {
return;
}
const lastAction = visibleReportActionItems[report.reportID];
const lastAction = lastVisibleReportActions[report.reportID];
if (!ReportActionUtils.isReportPreviewAction(lastAction)) {
return;
}
Expand All @@ -681,7 +681,7 @@ function getIOUReportIDOfLastAction(report: OnyxEntry<Report>): string | undefin
*/
function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails: Partial<PersonalDetails> | null, policy?: OnyxEntry<Policy>): string {
const reportID = report?.reportID ?? '-1';
const lastReportAction = visibleReportActionItems[reportID] ?? null;
const lastReportAction = lastVisibleReportActions[reportID] ?? null;

// some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action
const lastOriginalReportAction = lastReportActions[reportID] ?? null;
Expand Down Expand Up @@ -852,7 +852,7 @@ function createOption(
const lastMessageTextFromReport = getLastMessageTextForReport(report, lastActorDetails);
let lastMessageText = lastMessageTextFromReport;

const lastAction = visibleReportActionItems[report.reportID];
const lastAction = lastVisibleReportActions[report.reportID];
const shouldDisplayLastActorName = lastAction && lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastAction.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU;

if (shouldDisplayLastActorName && lastActorDisplayName && lastMessageTextFromReport) {
Expand Down