Skip to content

Commit

Permalink
Merge pull request #22008 from Expensify/report-lastactor-migration
Browse files Browse the repository at this point in the history
Remove all uses of report.lastActorEmail
  • Loading branch information
Beamanator authored Jul 10, 2023
2 parents 2e3f8c2 + d4ceeb6 commit cc49692
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 69 deletions.
124 changes: 74 additions & 50 deletions src/libs/E2E/apiMocks/openApp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/libs/E2E/apiMocks/openReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default () => ({
lastVisibleActionCreated: '2022-08-01 20:49:11',
lastMessageTimestamp: 1659386951000,
lastMessageText: 'Say hello\ud83d\ude10',
lastActorEmail: 'fake3@gmail.com',
lastActorAccountID: 10773236,
notificationPreference: 'always',
stateNum: 0,
statusNum: 0,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as LoginUtils from './LoginUtils';
import * as LocalePhoneNumber from './LocalePhoneNumber';
import * as UserUtils from './UserUtils';
import * as ReportActionUtils from './ReportActionsUtils';
import * as PersonalDetailsUtils from './PersonalDetailsUtils';

/**
* OptionsListUtils is used to build a list options passed to the OptionsList component. Several different UI views can
Expand Down Expand Up @@ -492,7 +493,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
(lastReportActions[report.reportID] && lastReportActions[report.reportID].originalMessage && lastReportActions[report.reportID].originalMessage.reason) ||
CONST.REPORT.ARCHIVE_REASON.DEFAULT;
lastMessageText = Localize.translate(preferredLocale, `reportArchiveReasons.${archiveReason}`, {
displayName: archiveReason.displayName || report.lastActorEmail,
displayName: archiveReason.displayName || PersonalDetailsUtils.getDisplayNameOrDefault(lastActorDetails, 'displayName'),
policyName: ReportUtils.getPolicyName(report),
});
}
Expand Down
1 change: 0 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,6 @@ function buildOptimisticChatReport(
hasOutstandingIOU: false,
isOwnPolicyExpenseChat,
isPinned: reportName === CONST.REPORT.WORKSPACE_CHAT_ROOMS.ADMINS,
lastActorEmail: '',
lastActorAccountID: 0,
lastMessageHtml: '',
lastMessageText: null,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as OptionsListUtils from './OptionsListUtils';
import * as CollectionUtils from './CollectionUtils';
import * as LocalePhoneNumber from './LocalePhoneNumber';
import * as UserUtils from './UserUtils';
import * as PersonalDetailsUtils from './PersonalDetailsUtils';

// Note: It is very important that the keys subscribed to here are the same
// keys that are connected to SidebarLinks withOnyx(). If there was a key missing from SidebarLinks and it's data was updated
Expand Down Expand Up @@ -308,7 +309,6 @@ function getOptionData(reportID) {
lastActorDetails = lastActorDisplayName
? {
displayName: lastActorDisplayName,
login: report.lastActorEmail,
accountID: report.lastActorAccountID,
}
: null;
Expand All @@ -322,7 +322,7 @@ function getOptionData(reportID) {
(lastReportActions[report.reportID] && lastReportActions[report.reportID].originalMessage && lastReportActions[report.reportID].originalMessage.reason) ||
CONST.REPORT.ARCHIVE_REASON.DEFAULT;
lastMessageText = Localize.translate(preferredLocale, `reportArchiveReasons.${archiveReason}`, {
displayName: archiveReason.displayName || report.lastActorEmail,
displayName: archiveReason.displayName || PersonalDetailsUtils.getDisplayNameOrDefault(lastActorDetails, 'displayName'),
policyName: ReportUtils.getPolicyName(report),
});
}
Expand Down
3 changes: 0 additions & 3 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import * as PersonalDetailsUtils from '../PersonalDetailsUtils';
import SidebarUtils from '../SidebarUtils';
import * as OptionsListUtils from '../OptionsListUtils';

let currentUserEmail;
let currentUserAccountID;
Onyx.connect({
key: ONYXKEYS.SESSION,
Expand All @@ -37,7 +36,6 @@ Onyx.connect({
return;
}

currentUserEmail = val.email;
currentUserAccountID = val.accountID;
},
});
Expand Down Expand Up @@ -252,7 +250,6 @@ function addActions(reportID, text = '', file) {
lastVisibleActionCreated: currentTime,
lastMessageText: lastCommentText,
lastMessageHtml: lastCommentText,
lastActorEmail: currentUserEmail,
lastActorAccountID: currentUserAccountID,
lastReadTime: currentTime,
};
Expand Down
4 changes: 0 additions & 4 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function createTaskAndNavigate(parentReportID, title, description, assignee, ass
const optimisticReport = {
lastVisibleActionCreated: currentTime,
lastMessageText: lastCommentText,
lastActorEmail: currentUserEmail,
lastActorAccountID: currentUserAccountID,
lastReadTime: currentTime,
};
Expand Down Expand Up @@ -144,7 +143,6 @@ function createTaskAndNavigate(parentReportID, title, description, assignee, ass
const optimisticAssigneeReport = {
lastVisibleActionCreated: currentTime,
lastMessageText: lastAssigneeCommentText,
lastActorEmail: currentUserEmail,
lastActorAccountID: currentUserAccountID,
lastReadTime: currentTime,
};
Expand Down Expand Up @@ -258,7 +256,6 @@ function reopenTask(taskReportID, taskTitle) {
statusNum: CONST.REPORT.STATUS.OPEN,
lastVisibleActionCreated: reopenedTaskReportAction.created,
lastMessageText: message,
lastActorEmail: currentUserEmail,
lastActorAccountID: reopenedTaskReportAction.actorAccountID,
lastReadTime: reopenedTaskReportAction.created,
},
Expand Down Expand Up @@ -594,7 +591,6 @@ function cancelTask(taskReportID, taskTitle, originalStateNum, originalStatusNum
value: {
lastVisibleActionCreated: optimisticCancelReportAction.created,
lastMessageText: message,
lastActorEmail: currentUserEmail,
lastActorAccountID: optimisticCancelReportAction.actorAccountID,
},
},
Expand Down
3 changes: 0 additions & 3 deletions src/pages/reportPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ export default PropTypes.shape({
/** Indicates if the report is pinned to the LHN or not */
isPinned: PropTypes.bool,

/** The email of the last message's actor */
lastActorEmail: PropTypes.string,

/** The accountID of the last message's actor */
lastActorAccountID: PropTypes.number,

Expand Down
7 changes: 3 additions & 4 deletions tests/actions/ReportTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('actions/Report', () => {
notificationPreference: 'always',
lastVisibleActionCreated: '2022-11-22 03:48:27.267',
lastMessageText: 'Testing a comment',
lastActorEmail: TEST_USER_LOGIN,
lastActorAccountID: TEST_USER_ACCOUNT_ID,
},
},
{
Expand Down Expand Up @@ -195,7 +195,6 @@ describe('actions/Report', () => {

const USER_1_LOGIN = 'user@test.com';
const USER_1_ACCOUNT_ID = 1;
const USER_2_LOGIN = 'different-user@test.com';
const USER_2_ACCOUNT_ID = 2;
return Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, {reportName: 'Test', reportID: REPORT_ID})
.then(() => TestHelper.signInWithTestUser(USER_1_ACCOUNT_ID, USER_1_LOGIN))
Expand All @@ -216,7 +215,7 @@ describe('actions/Report', () => {
reportID: REPORT_ID,
notificationPreference: 'always',
lastMessageText: 'Comment 1',
lastActorEmail: USER_2_LOGIN,
lastActorAccountID: USER_2_ACCOUNT_ID,
lastVisibleActionCreated: reportActionCreatedDate,
lastMentionedTime: reportActionCreatedDate,
lastReadTime: DateUtils.subtractMillisecondsFromDateTime(reportActionCreatedDate, 1),
Expand Down Expand Up @@ -359,7 +358,7 @@ describe('actions/Report', () => {
reportID: REPORT_ID,
notificationPreference: 'always',
lastMessageText: 'Current User Comment 3',
lastActorEmail: 'test@test.com',
lastActorAccountID: 1,
lastVisibleActionCreated: reportActionCreatedDate,
lastReadTime: reportActionCreatedDate,
},
Expand Down
1 change: 1 addition & 0 deletions tests/ui/UnreadIndicatorsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ describe('Unread Indicators', () => {
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, {
lastMessageText: lastReportAction.message[0].text,
lastVisibleActionCreated: DateUtils.getDBTime(lastReportAction.timestamp),
lastActorAccountID: lastReportAction.actorAccountID,
reportID: REPORT_ID,
});
return waitForPromisesToResolve();
Expand Down

0 comments on commit cc49692

Please sign in to comment.