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

Fix display name displays twice on LHN after receiving payment #37398

Merged
merged 2 commits into from
Mar 4, 2024
Merged
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
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 @@ -289,14 +287,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
Loading