From 2162be68a1c34cc56949637cee6a196b8e817563 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 29 Jun 2023 15:51:31 +0300 Subject: [PATCH 01/12] Remove actorEmail everywhere --- src/libs/ReportActionsUtils.js | 2 +- src/libs/ReportUtils.js | 12 +++--------- .../home/report/ContextMenu/ContextMenuActions.js | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index dc8ad305fee0..771e16872f5d 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -240,7 +240,7 @@ function isConsecutiveActionMadeByPreviousActor(reportActions, actionIndex) { return false; } - return currentAction.actorEmail === previousAction.actorEmail; + return currentAction.actorAccountID === previousAction.actorAccountID; } /** diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 97cbf184e795..76bdbfec7054 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -206,7 +206,7 @@ function sortReportsByLastRead(reports) { */ function canEditReportAction(reportAction) { return ( - reportAction.actorEmail === sessionEmail && + reportAction.actorAccountID === sessionAccountID && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && !isReportMessageAttachment(lodashGet(reportAction, ['message', 0], {})) && !ReportActionsUtils.isDeletedAction(reportAction) && @@ -260,7 +260,7 @@ function canDeleteReportAction(reportAction, reportID) { ) { return false; } - if (reportAction.actorEmail === sessionEmail) { + if (reportAction.actorAccountID === sessionAccountID) { return true; } const report = lodashGet(allReports, `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {}); @@ -1208,7 +1208,6 @@ function buildOptimisticAddCommentReportAction(text, file) { reportAction: { reportActionID: NumberUtils.rand64(), actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, - actorEmail: currentUserEmail, actorAccountID: currentUserAccountID, person: [ { @@ -1441,7 +1440,6 @@ function buildOptimisticIOUReportAction(type, amount, currency, comment, partici return { actionName: CONST.REPORT.ACTIONS.TYPE.IOU, actorAccountID: currentUserAccountID, - actorEmail: currentUserEmail, automatic: false, avatar: lodashGet(currentUserPersonalDetails, 'avatar', UserUtils.getDefaultAvatar(currentUserAccountID)), isAttachment: false, @@ -1480,7 +1478,6 @@ function buildOptimisticReportPreview(reportID, iouReportID, payeeAccountID) { originalMessage: { linkedReportID: iouReportID, }, - actorEmail: currentUserEmail, actorAccountID: currentUserAccountID, }; } @@ -1495,7 +1492,6 @@ function buildOptimisticTaskReportAction(taskReportID, actionName, message = '') return { actionName, actorAccountID: currentUserAccountID, - actorEmail: currentUserEmail, automatic: false, avatar: lodashGet(currentUserPersonalDetails, 'avatar', UserUtils.getDefaultAvatar(currentUserAccountID)), isAttachment: false, @@ -1594,7 +1590,6 @@ function buildOptimisticCreatedReportAction(ownerEmail) { actionName: CONST.REPORT.ACTIONS.TYPE.CREATED, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, actorAccountID: currentUserAccountID, - actorEmail: currentUserEmail, message: [ { type: CONST.REPORT.MESSAGE.TYPE.TEXT, @@ -1634,7 +1629,6 @@ function buildOptimisticEditedTaskReportAction(ownerEmail) { actionName: CONST.REPORT.ACTIONS.TYPE.TASKEDITED, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, actorAccountID: currentUserAccountID, - actorEmail: currentUserEmail, message: [ { type: CONST.REPORT.MESSAGE.TYPE.TEXT, @@ -2083,7 +2077,7 @@ function shouldShowFlagComment(reportAction, report) { !isArchivedRoom(report) && !chatIncludesChronos(report) && !isConciergeChatReport(report.reportID) && - reportAction.actorEmail !== CONST.EMAIL.CONCIERGE + reportAction.actorAccountID !== CONST.ACCOUNT_ID.CONCIERGE ); } diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 0a0388e414c7..7f36eb9ac8b3 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -325,7 +325,7 @@ export default [ !isArchivedRoom && !isChronosReport && !ReportUtils.isConciergeChatReport(reportID) && - reportAction.actorEmail !== CONST.EMAIL.CONCIERGE, + reportAction.actorAccountID !== CONST.ACCOUNT_ID.CONCIERGE, onPress: (closePopover, {reportID, reportAction}) => { if (closePopover) { hideContextMenu(false, () => Navigation.navigate(ROUTES.getFlagCommentRoute(reportID, reportAction.reportActionID))); From c3ff82febbb09130c3e3449fb7bcc8e145e661d0 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 29 Jun 2023 15:51:46 +0300 Subject: [PATCH 02/12] Update tests to remove actorEmail --- src/libs/E2E/apiMocks/openReport.js | 1 - tests/actions/IOUTest.js | 2 -- tests/actions/ReportTest.js | 3 --- tests/ui/UnreadIndicatorsTest.js | 19 +++++++++---------- tests/utils/TestHelper.js | 3 +-- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/libs/E2E/apiMocks/openReport.js b/src/libs/E2E/apiMocks/openReport.js index 3eb9c7890299..8ad00627b52a 100644 --- a/src/libs/E2E/apiMocks/openReport.js +++ b/src/libs/E2E/apiMocks/openReport.js @@ -67,7 +67,6 @@ export default () => ({ text: '123 Ios', }, ], - actorEmail: 'fake3@gmail.com', actorAccountID: 10773236, message: [ { diff --git a/tests/actions/IOUTest.js b/tests/actions/IOUTest.js index 112377f373d5..b9e30d1b0831 100644 --- a/tests/actions/IOUTest.js +++ b/tests/actions/IOUTest.js @@ -372,7 +372,6 @@ describe('actions/IOU', () => { const iouAction = { reportActionID: NumberUtils.rand64(), actionName: CONST.REPORT.ACTIONS.TYPE.IOU, - actorEmail: RORY_EMAIL, actorAccountID: RORY_ACCOUNT_ID, created: DateUtils.getDBTime(), originalMessage: { @@ -835,7 +834,6 @@ describe('actions/IOU', () => { const julesExistingIOUAction = { reportActionID: NumberUtils.rand64(), actionName: CONST.REPORT.ACTIONS.TYPE.IOU, - actorEmail: RORY_EMAIL, actorAccountID: RORY_ACCOUNT_ID, created: DateUtils.getDBTime(), originalMessage: { diff --git a/tests/actions/ReportTest.js b/tests/actions/ReportTest.js index e98a5249187f..6fbf3b88dd82 100644 --- a/tests/actions/ReportTest.js +++ b/tests/actions/ReportTest.js @@ -47,7 +47,6 @@ describe('actions/Report', () => { const REPORT_ACTION = { actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, actorAccountID: TEST_USER_ACCOUNT_ID, - actorEmail: TEST_USER_LOGIN, automatic: false, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', message: [{type: 'COMMENT', html: 'Testing a comment', text: 'Testing a comment'}], @@ -230,7 +229,6 @@ describe('actions/Report', () => { 1: { actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, actorAccountID: USER_2_ACCOUNT_ID, - actorEmail: USER_2_LOGIN, automatic: false, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', message: [{type: 'COMMENT', html: 'Comment 1', text: 'Comment 1'}], @@ -316,7 +314,6 @@ describe('actions/Report', () => { const USER_1_BASE_ACTION = { actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, actorAccountID: USER_1_ACCOUNT_ID, - actorEmail: USER_1_LOGIN, automatic: false, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', person: [{type: 'TEXT', style: 'strong', text: 'Test User'}], diff --git a/tests/ui/UnreadIndicatorsTest.js b/tests/ui/UnreadIndicatorsTest.js index c12b03c6ae18..5d24acae594d 100644 --- a/tests/ui/UnreadIndicatorsTest.js +++ b/tests/ui/UnreadIndicatorsTest.js @@ -176,15 +176,15 @@ function signInAndGetAppWithUnreadChat() { }, ], }, - 1: TestHelper.buildTestReportComment(USER_B_EMAIL, MOMENT_TEN_MINUTES_AGO.clone().add(10, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '1'), - 2: TestHelper.buildTestReportComment(USER_B_EMAIL, MOMENT_TEN_MINUTES_AGO.clone().add(20, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '2'), - 3: TestHelper.buildTestReportComment(USER_B_EMAIL, reportAction3CreatedDate, USER_B_ACCOUNT_ID, '3'), - 4: TestHelper.buildTestReportComment(USER_B_EMAIL, MOMENT_TEN_MINUTES_AGO.clone().add(40, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '4'), - 5: TestHelper.buildTestReportComment(USER_B_EMAIL, MOMENT_TEN_MINUTES_AGO.clone().add(50, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '5'), - 6: TestHelper.buildTestReportComment(USER_B_EMAIL, MOMENT_TEN_MINUTES_AGO.clone().add(60, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '6'), - 7: TestHelper.buildTestReportComment(USER_B_EMAIL, MOMENT_TEN_MINUTES_AGO.clone().add(70, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '7'), - 8: TestHelper.buildTestReportComment(USER_B_EMAIL, MOMENT_TEN_MINUTES_AGO.clone().add(80, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '8'), - 9: TestHelper.buildTestReportComment(USER_B_EMAIL, reportAction9CreatedDate, USER_B_ACCOUNT_ID, '9'), + 1: TestHelper.buildTestReportComment(MOMENT_TEN_MINUTES_AGO.clone().add(10, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '1'), + 2: TestHelper.buildTestReportComment(MOMENT_TEN_MINUTES_AGO.clone().add(20, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '2'), + 3: TestHelper.buildTestReportComment(reportAction3CreatedDate, USER_B_ACCOUNT_ID, '3'), + 4: TestHelper.buildTestReportComment(MOMENT_TEN_MINUTES_AGO.clone().add(40, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '4'), + 5: TestHelper.buildTestReportComment(MOMENT_TEN_MINUTES_AGO.clone().add(50, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '5'), + 6: TestHelper.buildTestReportComment(MOMENT_TEN_MINUTES_AGO.clone().add(60, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '6'), + 7: TestHelper.buildTestReportComment(MOMENT_TEN_MINUTES_AGO.clone().add(70, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '7'), + 8: TestHelper.buildTestReportComment(MOMENT_TEN_MINUTES_AGO.clone().add(80, 'seconds').format(MOMENT_FORMAT), USER_B_ACCOUNT_ID, '8'), + 9: TestHelper.buildTestReportComment(reportAction9CreatedDate, USER_B_ACCOUNT_ID, '9'), }); Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, { [USER_B_ACCOUNT_ID]: TestHelper.buildPersonalDetails(USER_B_EMAIL, USER_B_ACCOUNT_ID, 'B'), @@ -321,7 +321,6 @@ describe('Unread Indicators', () => { }, [commentReportActionID]: { actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, - actorEmail: USER_C_EMAIL, actorAccountID: USER_C_ACCOUNT_ID, person: [{type: 'TEXT', style: 'strong', text: 'User C'}], created: NEW_REPORT_FIST_MESSAGE_CREATED_MOMENT.format(MOMENT_FORMAT), diff --git a/tests/utils/TestHelper.js b/tests/utils/TestHelper.js index 4f3cf2d61aa6..eacc9f9ca7f6 100644 --- a/tests/utils/TestHelper.js +++ b/tests/utils/TestHelper.js @@ -202,11 +202,10 @@ function setPersonalDetails(login, accountID) { * @param {String} actionID * @returns {Object} */ -function buildTestReportComment(actorEmail, created, actorAccountID, actionID = null) { +function buildTestReportComment(created, actorAccountID, actionID = null) { const reportActionID = actionID || NumberUtils.rand64(); return { actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, - actorEmail, person: [{type: 'TEXT', style: 'strong', text: 'User B'}], created, message: [{type: 'COMMENT', html: `Comment ${actionID}`, text: `Comment ${actionID}`}], From e60c31847cec744358e14d30e9922ee98efd26ed Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 29 Jun 2023 16:35:31 +0300 Subject: [PATCH 03/12] Oops missed ya --- tests/utils/TestHelper.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/utils/TestHelper.js b/tests/utils/TestHelper.js index eacc9f9ca7f6..a8424d14ed33 100644 --- a/tests/utils/TestHelper.js +++ b/tests/utils/TestHelper.js @@ -196,7 +196,6 @@ function setPersonalDetails(login, accountID) { } /** - * @param {String} actorEmail * @param {String} created * @param {Number} actorAccountID * @param {String} actionID From f7d6e79b241502ed613e83a43c3c8fc4773c4156 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 29 Jun 2023 16:36:01 +0300 Subject: [PATCH 04/12] Use session email/accountID since they don't change much --- src/libs/actions/Task.js | 18 +++++++++++++----- src/pages/tasks/NewTaskPage.js | 2 -- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index 59a84182b803..737c57cd397f 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -13,6 +13,16 @@ import * as UserUtils from '../UserUtils'; import * as PersonalDetailsUtils from '../PersonalDetailsUtils'; import * as ReportActionsUtils from '../ReportActionsUtils'; +let currentUserEmail = ''; +let currentUserAccountID = 0; +Onyx.connect({ + key: ONYXKEYS.SESSION, + callback: (val) => { + currentUserEmail = lodashGet(val, 'email', ''); + currentUserAccountID = lodashGet(val, 'accountID', 0); + }, +}); + /** * Clears out the task info from the store */ @@ -24,8 +34,6 @@ function clearOutTaskInfo() { * Assign a task to a user * Function title is createTask for consistency with the rest of the actions * and also because we can create a task without assigning it to anyone - * @param {String} currentUserEmail - * @param {Number} currentUserAccountID * @param {String} parentReportID * @param {String} title * @param {String} description @@ -34,7 +42,7 @@ function clearOutTaskInfo() { * */ -function createTaskAndNavigate(currentUserEmail, currentUserAccountID, parentReportID, title, description, assignee, assigneeAccountID = 0) { +function createTaskAndNavigate(parentReportID, title, description, assignee, assigneeAccountID = 0) { // Create the task report const optimisticTaskReport = ReportUtils.buildOptimisticTaskReport(currentUserEmail, currentUserAccountID, assigneeAccountID, parentReportID, title, description); @@ -250,7 +258,7 @@ function reopenTask(taskReportID, taskTitle) { statusNum: CONST.REPORT.STATUS.OPEN, lastVisibleActionCreated: reopenedTaskReportAction.created, lastMessageText: message, - lastActorEmail: reopenedTaskReportAction.actorEmail, + lastActorEmail: currentUserEmail, lastActorAccountID: reopenedTaskReportAction.actorAccountID, lastReadTime: reopenedTaskReportAction.created, }, @@ -585,7 +593,7 @@ function cancelTask(taskReportID, taskTitle, originalStateNum, originalStatusNum value: { lastVisibleActionCreated: optimisticCancelReportAction.created, lastMessageText: message, - lastActorEmail: optimisticCancelReportAction.actorEmail, + lastActorEmail: currentUserEmail, lastActorAccountID: optimisticCancelReportAction.actorAccountID, }, }, diff --git a/src/pages/tasks/NewTaskPage.js b/src/pages/tasks/NewTaskPage.js index 127592601aec..c910ae996c68 100644 --- a/src/pages/tasks/NewTaskPage.js +++ b/src/pages/tasks/NewTaskPage.js @@ -121,8 +121,6 @@ function NewTaskPage(props) { } TaskUtils.createTaskAndNavigate( - props.session.email, - props.session.accountID, parentReport.reportID, props.task.title, props.task.description, From a4ac931117a82b53813dac99ecfd3cd82bcaca0d Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 29 Jun 2023 16:36:24 +0300 Subject: [PATCH 05/12] Remove actorEmail for good --- src/libs/ReportUtils.js | 9 ++++----- src/pages/home/report/ReportActionItemSingle.js | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 76bdbfec7054..9ed318618da0 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -226,7 +226,7 @@ function canEditReportAction(reportAction) { */ function canFlagReportAction(reportAction) { return ( - !loginList.includes(reportAction.actorEmail) && + reportAction.actorAccountID !== currentUserAccountID && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && !ReportActionsUtils.isDeletedAction(reportAction) && !ReportActionsUtils.isCreatedTaskReportAction(reportAction) @@ -737,12 +737,12 @@ function getIcons(report, personalDetails, defaultIcon = null, isPayer = false) if (isThread(report)) { const parentReportAction = ReportActionsUtils.getParentReportAction(report); - const actorEmail = lodashGet(parentReportAction, 'actorEmail', ''); - const actorAccountID = lodashGet(parentReportAction, 'actorAccountID', ''); + const actorAccountID = lodashGet(parentReportAction, 'actorAccountID', 0); + const actorDisplayName = lodashGet(allPersonalDetails, [actorAccountID, 'displayName'], ''); const actorIcon = { id: actorAccountID, source: UserUtils.getAvatar(lodashGet(personalDetails, [actorAccountID, 'avatar']), actorAccountID), - name: actorEmail, + name: actorDisplayName, type: CONST.ICON_TYPE_AVATAR, }; @@ -1793,7 +1793,6 @@ function buildOptimisticTaskReport(ownerEmail, ownerAccountID, assigneeAccountID description, ownerEmail, ownerAccountID, - // managerEmail: assignee, managerID: assigneeAccountID, type: CONST.REPORT.TYPE.TASK, parentReportID, diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index 59307bd66734..62e2156e6957 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -75,7 +75,7 @@ function ReportActionItemSingle(props) { const isWorkspaceActor = ReportUtils.isPolicyExpenseChat(props.report) && !actorAccountID; const actorDetails = props.personalDetailsList[actorAccountID] || {}; const displayName = isWorkspaceActor ? ReportUtils.getPolicyName(props.report) : actorDetails.displayName; - const actorHint = isWorkspaceActor ? displayName : lodashGet(props.action, 'actorEmail', '').replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); + const actorHint = displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); const pendingFields = isWorkspaceActor ? {} : actorDetails.pendingFields; const avatarSource = isWorkspaceActor ? ReportUtils.getWorkspaceAvatar(props.report) : UserUtils.getAvatar(actorDetails.avatar, actorAccountID); From d11464d2a901c7544a026c8f8eabf4de3a5b582e Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 29 Jun 2023 16:43:01 +0300 Subject: [PATCH 06/12] Clean up unused subscription --- src/libs/ReportUtils.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 9ed318618da0..5553893818d2 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -40,12 +40,6 @@ Onyx.connect({ }, }); -let loginList; -Onyx.connect({ - key: ONYXKEYS.LOGIN_LIST, - callback: (val) => (loginList = _.isEmpty(val) ? [] : _.keys(val)), -}); - let preferredLocale = CONST.LOCALES.DEFAULT; Onyx.connect({ key: ONYXKEYS.NVP_PREFERRED_LOCALE, From 36c3879c8139640ac556d1fdfc95196563e889e7 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Thu, 29 Jun 2023 17:06:14 +0300 Subject: [PATCH 07/12] Prettify --- src/pages/tasks/NewTaskPage.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/pages/tasks/NewTaskPage.js b/src/pages/tasks/NewTaskPage.js index c910ae996c68..2cbc8e955441 100644 --- a/src/pages/tasks/NewTaskPage.js +++ b/src/pages/tasks/NewTaskPage.js @@ -120,13 +120,7 @@ function NewTaskPage(props) { return; } - TaskUtils.createTaskAndNavigate( - parentReport.reportID, - props.task.title, - props.task.description, - props.task.assignee, - props.task.assigneeAccountID, - ); + TaskUtils.createTaskAndNavigate(parentReport.reportID, props.task.title, props.task.description, props.task.assignee, props.task.assigneeAccountID); } if (!Permissions.canUseTasks(props.betas)) { From 312b4ad0c5299db7ec9f4c3fa7c86dd0d0ac6278 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Fri, 30 Jun 2023 11:29:43 +0300 Subject: [PATCH 08/12] Remove useless defaults --- src/libs/actions/Task.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index 737c57cd397f..38072ea6669d 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -13,8 +13,8 @@ import * as UserUtils from '../UserUtils'; import * as PersonalDetailsUtils from '../PersonalDetailsUtils'; import * as ReportActionsUtils from '../ReportActionsUtils'; -let currentUserEmail = ''; -let currentUserAccountID = 0; +let currentUserEmail; +let currentUserAccountID; Onyx.connect({ key: ONYXKEYS.SESSION, callback: (val) => { From d1b3e656893dc92b172ca1a0979e6f6710f1eb32 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Mon, 3 Jul 2023 13:32:47 +0300 Subject: [PATCH 09/12] Remove old onyx key connection --- src/pages/tasks/NewTaskPage.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/pages/tasks/NewTaskPage.js b/src/pages/tasks/NewTaskPage.js index 785644731ece..8098fbd2d633 100644 --- a/src/pages/tasks/NewTaskPage.js +++ b/src/pages/tasks/NewTaskPage.js @@ -47,11 +47,6 @@ const propTypes = { }), ), - /** Current user session */ - session: PropTypes.shape({ - email: PropTypes.string.isRequired, - }), - /** All reports shared with the user */ reports: PropTypes.objectOf(reportPropTypes), @@ -63,7 +58,6 @@ const defaultProps = { task: {}, personalDetails: {}, reports: {}, - session: {}, }; function NewTaskPage(props) { @@ -198,9 +192,6 @@ export default compose( personalDetails: { key: ONYXKEYS.PERSONAL_DETAILS_LIST, }, - session: { - key: ONYXKEYS.SESSION, - }, }), withLocalize, )(NewTaskPage); From 3ec735cf22fbe5cb0a0e130a1eb80267a673829d Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Tue, 4 Jul 2023 16:09:07 +0300 Subject: [PATCH 10/12] Try setting actor hint w/ login then displayName --- src/pages/home/report/ReportActionItemSingle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index f92d3a9d732a..77dec326425b 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -72,9 +72,9 @@ const showWorkspaceDetails = (reportID) => { function ReportActionItemSingle(props) { const actorAccountID = props.action.actorAccountID; - let {displayName} = props.personalDetailsList[actorAccountID] || {}; + let {displayName, login} = props.personalDetailsList[actorAccountID] || {}; const {avatar, pendingFields} = props.personalDetailsList[actorAccountID] || {}; - let actorHint = displayName.replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); + let actorHint = (login || displayName).replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); const isWorkspaceActor = ReportUtils.isPolicyExpenseChat(props.report) && !actorAccountID; let avatarSource = UserUtils.getAvatar(avatar, actorAccountID); From 50c362a4d5c38fda5b4082de8d2550a374f1f6d2 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Tue, 4 Jul 2023 16:15:05 +0300 Subject: [PATCH 11/12] Login is a const here --- src/pages/home/report/ReportActionItemSingle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index 77dec326425b..875b899d9926 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -72,8 +72,8 @@ const showWorkspaceDetails = (reportID) => { function ReportActionItemSingle(props) { const actorAccountID = props.action.actorAccountID; - let {displayName, login} = props.personalDetailsList[actorAccountID] || {}; - const {avatar, pendingFields} = props.personalDetailsList[actorAccountID] || {}; + let {displayName} = props.personalDetailsList[actorAccountID] || {}; + const {avatar, login, pendingFields} = props.personalDetailsList[actorAccountID] || {}; let actorHint = (login || displayName).replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); const isWorkspaceActor = ReportUtils.isPolicyExpenseChat(props.report) && !actorAccountID; let avatarSource = UserUtils.getAvatar(avatar, actorAccountID); From 9e0cabf139f091190939f0f93dc40efa65839ceb Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Tue, 4 Jul 2023 16:15:14 +0300 Subject: [PATCH 12/12] Fix bad manual merge --- src/libs/ReportUtils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 8647893f1fdf..0d0552d51e48 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -36,6 +36,12 @@ Onyx.connect({ }, }); +let loginList; +Onyx.connect({ + key: ONYXKEYS.LOGIN_LIST, + callback: (val) => (loginList = _.isEmpty(val) ? [] : _.keys(val)), +}); + let preferredLocale = CONST.LOCALES.DEFAULT; Onyx.connect({ key: ONYXKEYS.NVP_PREFERRED_LOCALE,