From 4005248bb13d4657406b96757e1b60e64cbbb3cd Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Mon, 13 Mar 2023 11:12:43 +0000 Subject: [PATCH 1/3] fix: get last actor details from last report action if not present in personal details --- src/libs/SidebarUtils.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index 5cf2514efcd8..28646718ce87 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -1,5 +1,6 @@ import Onyx from 'react-native-onyx'; import _ from 'underscore'; +import lodashGet from 'lodash/get'; import lodashOrderBy from 'lodash/orderBy'; import Str from 'expensify-common/lib/str'; import ONYXKEYS from '../ONYXKEYS'; @@ -249,7 +250,16 @@ function getOptionData(reportID) { lastMessageTextFromReport = Str.htmlDecode(report ? report.lastMessageText : ''); } - const lastActorDetails = personalDetails[report.lastActorEmail] || null; + // If the last actor details is not in currently saved in the existing details in Onyx, + // then we need to get them from the last report info + let lastActorDetails = personalDetails[report.lastActorEmail] || null; + if (!lastActorDetails && lastReportActions[report.reportID]) { + const lastActorDisplayName = lodashGet(lastReportActions[report.reportID], 'person[0].text'); + lastActorDetails = lastActorDisplayName ? { + displayName: lastActorDisplayName, + login: lastReportActions[report.reportID].actorEmail, + } : null; + } let lastMessageText = hasMultipleParticipants && lastActorDetails && (lastActorDetails.login !== currentUserLogin.email) ? `${lastActorDetails.displayName}: ` : ''; From 36b2b57e6a8b81f5a6244116e984897f02551d5d Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 14 Mar 2023 15:10:34 +0000 Subject: [PATCH 2/3] fix: use lastActorEmail from report and fix comment english --- src/libs/SidebarUtils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index 28646718ce87..7d3ae8bfd495 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -250,14 +250,14 @@ function getOptionData(reportID) { lastMessageTextFromReport = Str.htmlDecode(report ? report.lastMessageText : ''); } - // If the last actor details is not in currently saved in the existing details in Onyx, - // then we need to get them from the last report info + // If the last actor's details are not currently saved in Onyx Collection, + // then try to get that from the last report action. let lastActorDetails = personalDetails[report.lastActorEmail] || null; if (!lastActorDetails && lastReportActions[report.reportID]) { const lastActorDisplayName = lodashGet(lastReportActions[report.reportID], 'person[0].text'); lastActorDetails = lastActorDisplayName ? { displayName: lastActorDisplayName, - login: lastReportActions[report.reportID].actorEmail, + login: report.lastActorEmail, } : null; } let lastMessageText = hasMultipleParticipants && lastActorDetails && (lastActorDetails.login !== currentUserLogin.email) From 5ec25ce5d85d20d865a85a51daa3e53d33b3d202 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Fri, 17 Mar 2023 16:10:16 +0000 Subject: [PATCH 3/3] fix: add check for action type created --- src/libs/SidebarUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index 7d3ae8bfd495..3e6fd500c98e 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -253,7 +253,7 @@ function getOptionData(reportID) { // If the last actor's details are not currently saved in Onyx Collection, // then try to get that from the last report action. let lastActorDetails = personalDetails[report.lastActorEmail] || null; - if (!lastActorDetails && lastReportActions[report.reportID]) { + if (!lastActorDetails && lastReportActions[report.reportID] && lastReportActions[report.reportID].actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED) { const lastActorDisplayName = lodashGet(lastReportActions[report.reportID], 'person[0].text'); lastActorDetails = lastActorDisplayName ? { displayName: lastActorDisplayName,