Skip to content

Commit

Permalink
Merge pull request #37398 from dukenv0307/fix/34525
Browse files Browse the repository at this point in the history
Fix display name displays twice on LHN after receiving payment
  • Loading branch information
MariaHCD authored Mar 4, 2024
2 parents 8f58c57 + 2419ba6 commit 4231ac9
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import * as TaskUtils from './TaskUtils';
import * as UserUtils from './UserUtils';

const visibleReportActionItems: ReportActions = {};
const lastReportActions: ReportActions = {};

Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
Expand All @@ -34,7 +33,6 @@ Onyx.connect({
const reportID = CollectionUtils.extractCollectionItemID(key);

const actionsArray: ReportAction[] = ReportActionsUtils.getSortedReportActions(Object.values(actions));
lastReportActions[reportID] = actionsArray[actionsArray.length - 1];

// The report is only visible if it is the last action not deleted that
// does not match a closed or created state.
Expand Down Expand Up @@ -303,14 +301,12 @@ function getOptionData({

let lastMessageText = lastMessageTextFromReport;

const reportAction = lastReportActions?.[report.reportID];
const lastAction = visibleReportActionItems[report.reportID];

const isThreadMessage =
ReportUtils.isThread(report) && reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && reportAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
ReportUtils.isThread(report) && lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && lastAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;

if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !result.isArchivedRoom) {
const lastAction = visibleReportActionItems[report.reportID];

if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) {
const newName = lastAction?.originalMessage?.newName ?? '';
result.alternateText = Localize.translate(preferredLocale, 'newRoomPage.roomRenamedTo', {newName});
Expand Down

0 comments on commit 4231ac9

Please sign in to comment.