diff --git a/src/components/ArchivedReportFooter.js b/src/components/ArchivedReportFooter.js
index d7a138d9a473..70741f352089 100644
--- a/src/components/ArchivedReportFooter.js
+++ b/src/components/ArchivedReportFooter.js
@@ -50,7 +50,7 @@ const defaultProps = {
function ArchivedReportFooter(props) {
const archiveReason = lodashGet(props.reportClosedAction, 'originalMessage.reason', CONST.REPORT.ARCHIVE_REASON.DEFAULT);
- let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [props.report.ownerAccountID, 'displayName'], props.report.ownerEmail);
+ let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [props.report.ownerAccountID, 'displayName']);
let oldDisplayName;
if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED) {
diff --git a/src/components/OptionRow.js b/src/components/OptionRow.js
index 25bd487f391a..01baa55cdd19 100644
--- a/src/components/OptionRow.js
+++ b/src/components/OptionRow.js
@@ -100,7 +100,7 @@ class OptionRow extends Component {
this.props.option.descriptiveText !== nextProps.option.descriptiveText ||
this.props.option.brickRoadIndicator !== nextProps.option.brickRoadIndicator ||
this.props.option.shouldShowSubscript !== nextProps.option.shouldShowSubscript ||
- this.props.option.ownerEmail !== nextProps.option.ownerEmail ||
+ this.props.option.ownerAccountID !== nextProps.option.ownerAccountID ||
this.props.option.subtitle !== nextProps.option.subtitle ||
this.props.option.pendingAction !== nextProps.option.pendingAction ||
this.props.option.customIcon !== nextProps.option.customIcon
diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js
index 2f584eff2f7b..df68159265c3 100644
--- a/src/components/ReportActionItem/IOUPreview.js
+++ b/src/components/ReportActionItem/IOUPreview.js
@@ -63,9 +63,6 @@ const propTypes = {
/** Account ID of the manager in this iou report */
managerID: PropTypes.number,
- /** Email address of the creator of this iou report */
- ownerEmail: PropTypes.string,
-
/** Account ID of the creator of this iou report */
ownerAccountID: PropTypes.number,
diff --git a/src/components/ReportActionItem/ReportPreview.js b/src/components/ReportActionItem/ReportPreview.js
index 4f574da513a0..41ee8098f755 100644
--- a/src/components/ReportActionItem/ReportPreview.js
+++ b/src/components/ReportActionItem/ReportPreview.js
@@ -47,8 +47,8 @@ const propTypes = {
/** Email address of the manager in this iou report */
managerEmail: PropTypes.string,
- /** Email address of the creator of this iou report */
- ownerEmail: PropTypes.string,
+ /** AccountID of the creator of this iou report */
+ ownerAccountID: PropTypes.number,
/** Outstanding amount in cents of this transaction */
total: PropTypes.number,
diff --git a/src/components/ReportActionItem/TaskAction.js b/src/components/ReportActionItem/TaskAction.js
index bdf8f374dde3..12a7b754a524 100644
--- a/src/components/ReportActionItem/TaskAction.js
+++ b/src/components/ReportActionItem/TaskAction.js
@@ -25,8 +25,8 @@ const propTypes = {
/** Email address of the manager in this iou report */
managerEmail: PropTypes.string,
- /** Email address of the creator of this iou report */
- ownerEmail: PropTypes.string,
+ /** AccountID of the creator of this iou report */
+ ownerAccountID: PropTypes.number,
}),
...withLocalizePropTypes,
diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js
index 621f3b90cbc3..7d17a44548b0 100644
--- a/src/components/ReportActionItem/TaskPreview.js
+++ b/src/components/ReportActionItem/TaskPreview.js
@@ -44,8 +44,8 @@ const propTypes = {
/** Email address of the manager in this iou report */
managerEmail: PropTypes.string,
- /** Email address of the creator of this iou report */
- ownerEmail: PropTypes.string,
+ /** AccountID of the creator of this iou report */
+ ownerAccountID: PropTypes.number,
}),
...withLocalizePropTypes,
diff --git a/src/components/ReportWelcomeText.js b/src/components/ReportWelcomeText.js
index 7c1b0252bee4..84ee3d73c874 100644
--- a/src/components/ReportWelcomeText.js
+++ b/src/components/ReportWelcomeText.js
@@ -72,8 +72,9 @@ function ReportWelcomeText(props) {
<>
{props.translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne')}
- {/* Use the policyExpenseChat owner's first name or their email if it's undefined or an empty string */}
- {lodashGet(props.personalDetails, [props.report.ownerAccountID, 'firstName']) || props.report.ownerEmail}
+ {/* Use the policyExpenseChat owner's first name or their display name if it's undefined or an empty string */}
+ {lodashGet(props.personalDetails, [props.report.ownerAccountID, 'firstName']) ||
+ lodashGet(props.personalDetails, [props.report.ownerAccountID, 'displayName'], '')}
{props.translate('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo')}
{ReportUtils.getPolicyName(props.report)}
diff --git a/src/libs/E2E/apiMocks/openApp.js b/src/libs/E2E/apiMocks/openApp.js
index 005bd005c5d4..8f8e6567e6d1 100644
--- a/src/libs/E2E/apiMocks/openApp.js
+++ b/src/libs/E2E/apiMocks/openApp.js
@@ -1573,7 +1573,7 @@ export default () => ({
reportID: '98258097',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['concierge@expensify.com'],
isPinned: true,
@@ -1599,7 +1599,7 @@ export default () => ({
reportID: '98258458',
reportName: '',
chatType: 'policyExpenseChat',
- ownerEmail: 'applausetester+perf2@applause.expensifail.com',
+ ownerAccountID: 17,
policyID: 'C28C2634DD7226B8',
participants: ['applausetester@applause.expensifail.com', 'applausetester+perf2@applause.expensifail.com'],
isPinned: false,
@@ -1621,7 +1621,7 @@ export default () => ({
reportID: '98344717',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['applausetester+ihchat4@applause.expensifail.com'],
isPinned: false,
@@ -1643,7 +1643,7 @@ export default () => ({
reportID: '98345050',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['fake3@gmail.com'],
isPinned: false,
@@ -1665,7 +1665,7 @@ export default () => ({
reportID: '98345315',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['fake3@gmail.com', 'fake6@gmail.com', 'fake7@gmail.com', 'fake8@gmail.com'],
isPinned: false,
@@ -1687,7 +1687,7 @@ export default () => ({
reportID: '98345625',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['fake1@gmail.com', 'fake2@gmail.com', 'fake3@gmail.com', 'fake4@gmail.com', 'fake5@gmail.com', 'fake6@gmail.com', 'fake7@gmail.com', 'fake8@gmail.com'],
isPinned: false,
@@ -1709,7 +1709,7 @@ export default () => ({
reportID: '98345679',
reportName: '',
chatType: 'policyExpenseChat',
- ownerEmail: 'applausetester+perf2@applause.expensifail.com',
+ ownerAccountID: 17,
policyID: '1CE001C4B9F3CA54',
participants: ['fake3@gmail.com', 'applausetester+perf2@applause.expensifail.com'],
isPinned: false,
@@ -1731,7 +1731,7 @@ export default () => ({
reportID: '98414813',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['applausetester+ihchat4@applause.expensifail.com', 'fake6@gmail.com'],
isPinned: false,
@@ -1753,7 +1753,7 @@ export default () => ({
reportID: '98817646',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['fake6@gmail.com'],
isPinned: false,
@@ -1776,7 +1776,7 @@ export default () => ({
reportID: '358751490033727',
reportName: '#digimobileroom',
chatType: 'policyRoom',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: 'C28C2634DD7226B8',
participants: ['applausetester+pd1005@applause.expensifail.com'],
isPinned: false,
@@ -1798,7 +1798,7 @@ export default () => ({
reportID: '663424408122117',
reportName: '#announce',
chatType: 'policyAnnounce',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: 'A6511FF8D2EE7661',
participants: ['applausetester+perf2@applause.expensifail.com'],
isPinned: false,
@@ -1820,7 +1820,7 @@ export default () => ({
reportID: '944123936554214',
reportName: '',
chatType: 'policyExpenseChat',
- ownerEmail: 'applausetester+perf2@applause.expensifail.com',
+ ownerAccountID: 17,
policyID: 'A6511FF8D2EE7661',
participants: ['applausetester+perf2@applause.expensifail.com'],
isPinned: false,
@@ -1842,7 +1842,7 @@ export default () => ({
reportID: '2242399088152511',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: [
'concierge@expensify.com',
@@ -1870,7 +1870,7 @@ export default () => ({
reportID: '2576922422943214',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['applausetester+42222abb@applause.expensifail.com'],
isPinned: false,
@@ -1892,7 +1892,7 @@ export default () => ({
reportID: '2752461403207161',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['fake1@gmail.com'],
isPinned: false,
@@ -1914,7 +1914,7 @@ export default () => ({
reportID: '3785654888638968',
reportName: '#jack',
chatType: 'policyRoom',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: 'C28C2634DD7226B8',
participants: ['applausetester+pd1005@applause.expensifail.com'],
isPinned: false,
@@ -1936,7 +1936,7 @@ export default () => ({
reportID: '4867098979334014',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['christoph+hightraffic@margelo.io'],
isPinned: false,
@@ -1959,7 +1959,7 @@ export default () => ({
reportID: '5277760851229035',
reportName: '#kasper_tha_cat',
chatType: 'policyRoom',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: 'C28C2634DD7226B8',
participants: ['applausetester+pd1005@applause.expensifail.com'],
isPinned: false,
@@ -1983,7 +1983,7 @@ export default () => ({
reportID: '5324367938904284',
reportName: '#applause.expensifail.com',
chatType: 'domainAll',
- ownerEmail: '+@applause.expensifail.com',
+ ownerAccountID: 99,
policyID: '_FAKE_',
participants: ['applausetester+bernardo@applause.expensifail.com'],
isPinned: false,
@@ -2005,7 +2005,7 @@ export default () => ({
reportID: '5654270288238256',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: [
'andreylazutkinutest@gmail.com',
@@ -2036,7 +2036,7 @@ export default () => ({
reportID: '6194900075541844',
reportName: '#admins',
chatType: 'policyAdmins',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: 'A6511FF8D2EE7661',
participants: ['applausetester+perf2@applause.expensifail.com'],
isPinned: false,
@@ -2058,7 +2058,7 @@ export default () => ({
reportID: '6801643744224146',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: [
'concierge@expensify.com',
@@ -2090,7 +2090,7 @@ export default () => ({
reportID: '7658708888047100',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: [
'concierge@expensify.com',
@@ -2119,7 +2119,7 @@ export default () => ({
reportID: '7756405299640824',
reportName: '#jackd23',
chatType: 'policyRoom',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: 'C28C2634DD7226B8',
participants: ['applausetester+pd1005@applause.expensifail.com'],
isPinned: false,
@@ -2141,7 +2141,7 @@ export default () => ({
reportID: '7819732651025410',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['fake5@gmail.com'],
isPinned: false,
@@ -2161,7 +2161,7 @@ export default () => ({
},
report_2543745284790730: {
reportID: '2543745284790730',
- ownerEmail: 'applausetester+perf2@applause.expensifail.com',
+ ownerAccountID: 17,
managerEmail: 'fake6@gmail.com',
currency: 'USD',
chatReportID: '98817646',
@@ -2174,7 +2174,7 @@ export default () => ({
},
report_4249286573496381: {
reportID: '4249286573496381',
- ownerEmail: 'applausetester+perf2@applause.expensifail.com',
+ ownerAccountID: 17,
managerEmail: 'christoph+hightraffic@margelo.io',
currency: 'USD',
chatReportID: '4867098979334014',
diff --git a/src/libs/E2E/apiMocks/openReport.js b/src/libs/E2E/apiMocks/openReport.js
index 8ad00627b52a..d4c5acc976fe 100644
--- a/src/libs/E2E/apiMocks/openReport.js
+++ b/src/libs/E2E/apiMocks/openReport.js
@@ -7,7 +7,7 @@ export default () => ({
reportID: '98345625',
reportName: 'Chat Report',
chatType: '',
- ownerEmail: '__fake__',
+ ownerAccountID: 0,
policyID: '_FAKE_',
participants: ['fake1@gmail.com', 'fake2@gmail.com', 'fake3@gmail.com', 'fake4@gmail.com', 'fake5@gmail.com', 'fake6@gmail.com', 'fake7@gmail.com', 'fake8@gmail.com'],
isPinned: false,
diff --git a/src/libs/IOUUtils.js b/src/libs/IOUUtils.js
index 64cfc078a138..093ed61061ea 100644
--- a/src/libs/IOUUtils.js
+++ b/src/libs/IOUUtils.js
@@ -25,8 +25,8 @@ function calculateAmount(numberOfParticipants, total, isDefaultUser = false) {
/**
* The owner of the IOU report is the account who is owed money and the manager is the one who owes money!
* In case the owner/manager swap, we need to update the owner of the IOU report and the report total, since it is always positive.
- * For example: if user1 owes user2 $10, then we have: {ownerEmail: user2, managerEmail: user1, total: $10 (a positive amount, owed to user2)}
- * If user1 requests $17 from user2, then we have: {ownerEmail: user1, managerEmail: user2, total: $7 (still a positive amount, but now owed to user1)}
+ * For example: if user1 owes user2 $10, then we have: {ownerAccountID: user2, managerEmail: user1, total: $10 (a positive amount, owed to user2)}
+ * If user1 requests $17 from user2, then we have: {ownerAccountID: user1, managerEmail: user2, total: $7 (still a positive amount, but now owed to user1)}
*
* @param {Object} iouReport
* @param {Number} actorAccountID
@@ -53,8 +53,6 @@ function updateIOUOwnerAndTotal(iouReport, actorAccountID, amount, currency, typ
// The total sign has changed and hence we need to flip the manager and owner of the report.
iouReportUpdate.ownerAccountID = iouReport.managerID;
iouReportUpdate.managerID = iouReport.ownerAccountID;
- iouReportUpdate.ownerEmail = iouReport.managerEmail;
- iouReportUpdate.managerEmail = iouReport.ownerEmail;
iouReportUpdate.total = -iouReportUpdate.total;
}
diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js
index d64ca187cda1..01a3b93d4b8e 100644
--- a/src/libs/OptionsListUtils.js
+++ b/src/libs/OptionsListUtils.js
@@ -62,7 +62,7 @@ const iouReports = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
callback: (report, key) => {
- if (!report || !key || !report.ownerEmail) {
+ if (!report || !key || !_.isNumber(report.ownerAccountID)) {
return;
}
@@ -423,7 +423,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
brickRoadIndicator: null,
icons: null,
tooltipText: null,
- ownerEmail: null,
+ ownerAccountID: null,
subtitle: null,
participantsList: null,
accountID: 0,
@@ -469,7 +469,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
result.allReportErrors = getAllReportErrors(report, reportActions);
result.brickRoadIndicator = !_.isEmpty(result.allReportErrors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '';
result.pendingAction = report.pendingFields ? report.pendingFields.addWorkspaceRoom || report.pendingFields.createChat : null;
- result.ownerEmail = report.ownerEmail;
+ result.ownerAccountID = report.ownerAccountID;
result.reportID = report.reportID;
result.isUnread = ReportUtils.isUnread(report);
result.hasDraftComment = report.hasDraft;
@@ -718,7 +718,7 @@ function getOptions(
}
const isCurrentUserOwnedPolicyExpenseChatThatCouldShow =
- reportOption.isPolicyExpenseChat && reportOption.ownerEmail === currentUserLogin && includeOwnedWorkspaceChats && !reportOption.isArchivedRoom;
+ reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption.isArchivedRoom;
// Skip if we aren't including multiple participant reports and this report has multiple participants
if (!isCurrentUserOwnedPolicyExpenseChatThatCouldShow && !includeMultipleParticipantReports && !reportOption.login) {
diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js
index e481f83c707c..35a482596afa 100644
--- a/src/libs/ReportUtils.js
+++ b/src/libs/ReportUtils.js
@@ -1004,7 +1004,7 @@ function getMoneyRequestTotal(report, moneyRequestReports = {}) {
* @returns {String}
*/
function getPolicyExpenseChatName(report) {
- const reportOwnerDisplayName = getDisplayNameForParticipant(report.ownerAccountID) || report.ownerEmail || report.reportName;
+ const reportOwnerDisplayName = getDisplayNameForParticipant(report.ownerAccountID) || lodashGet(allPersonalDetails, [report.ownerAccountID, 'login']) || report.reportName;
// If the policy expense chat is owned by this user, use the name of the policy as the report name.
if (report.isOwnPolicyExpenseChat) {
diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js
index 1e7a9131df2f..b29936430fa4 100644
--- a/src/libs/SidebarUtils.js
+++ b/src/libs/SidebarUtils.js
@@ -234,7 +234,6 @@ function getOptionData(reportID) {
brickRoadIndicator: null,
icons: null,
tooltipText: null,
- ownerEmail: null,
ownerAccountID: null,
subtitle: null,
participantsList: null,
@@ -279,7 +278,6 @@ function getOptionData(reportID) {
result.pendingAction = report.pendingFields ? report.pendingFields.addWorkspaceRoom || report.pendingFields.createChat : null;
result.allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions);
result.brickRoadIndicator = !_.isEmpty(result.allReportErrors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '';
- result.ownerEmail = report.ownerEmail;
result.ownerAccountID = report.ownerAccountID;
result.reportID = report.reportID;
result.isUnread = ReportUtils.isUnread(report);
diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js
index 8fd0ed6ce1ff..fe7934e3e591 100644
--- a/src/libs/actions/App.js
+++ b/src/libs/actions/App.js
@@ -210,7 +210,7 @@ function setUpPoliciesAndNavigate(session) {
// Approved Accountants and Guides can enter a flow where they make a workspace for other users,
// and those are passed as a search parameter when using transition links
- const ownerEmail = url.searchParams.get('ownerEmail');
+ const policyOwnerEmail = url.searchParams.get('ownerEmail');
const makeMeAdmin = url.searchParams.get('makeMeAdmin');
const policyName = url.searchParams.get('policyName');
@@ -222,7 +222,7 @@ function setUpPoliciesAndNavigate(session) {
const shouldCreateFreePolicy = !isLoggingInAsNewUser && isTransitioningFromOldDot && exitTo === ROUTES.WORKSPACE_NEW;
if (shouldCreateFreePolicy) {
- Policy.createWorkspace(ownerEmail, makeMeAdmin, policyName, true);
+ Policy.createWorkspace(policyOwnerEmail, makeMeAdmin, policyName, true);
return;
}
if (!isLoggingInAsNewUser && exitTo) {
diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js
index bad48978b0e1..307181b28e89 100644
--- a/src/libs/actions/Policy.js
+++ b/src/libs/actions/Policy.js
@@ -821,15 +821,15 @@ function generatePolicyID() {
/**
* Optimistically creates a new workspace and default workspace chats
*
- * @param {String} [ownerEmail] Optional, the email of the account to make the owner of the policy
+ * @param {String} [policyOwnerEmail] Optional, the email of the account to make the owner of the policy
* @param {Boolean} [makeMeAdmin] Optional, leave the calling account as an admin on the policy
* @param {String} [policyName] Optional, custom policy name we will use for created workspace
* @param {Boolean} [transitionFromOldDot] Optional, if the user is transitioning from old dot
* @returns {Promise}
*/
-function createWorkspace(ownerEmail = '', makeMeAdmin = false, policyName = '', transitionFromOldDot = false) {
+function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName = '', transitionFromOldDot = false) {
const policyID = generatePolicyID();
- const workspaceName = policyName || generateDefaultWorkspaceName(ownerEmail);
+ const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail);
const {
announceChatReportID,
@@ -853,7 +853,7 @@ function createWorkspace(ownerEmail = '', makeMeAdmin = false, policyName = '',
announceChatReportID,
adminsChatReportID,
expenseChatReportID,
- ownerEmail,
+ ownerEmail: policyOwnerEmail,
makeMeAdmin,
policyName: workspaceName,
type: CONST.POLICY.TYPE.FREE,
diff --git a/src/libs/actions/Welcome.js b/src/libs/actions/Welcome.js
index ddd0d872ce97..0a866e0c8c81 100644
--- a/src/libs/actions/Welcome.js
+++ b/src/libs/actions/Welcome.js
@@ -16,7 +16,7 @@ let isReadyPromise = new Promise((resolve) => {
let isFirstTimeNewExpensifyUser;
let isLoadingReportData = true;
-let email = '';
+let currentUserAccountID;
/**
* Check that a few requests have completed so that the welcome action can proceed:
@@ -92,7 +92,7 @@ Onyx.connect({
return;
}
- email = val.email;
+ currentUserAccountID = val.accountID;
},
});
@@ -119,7 +119,10 @@ function show({routes, showCreateMenu = () => {}, showPopoverMenu = () => {}}) {
const isDisplayingWorkspaceRoute = isWorkspaceRoute || exitingToWorkspaceRoute;
// We want to display the Workspace chat first since that means a user is already in a Workspace and doesn't need to create another one
- const workspaceChatReport = _.find(allReports, (report) => ReportUtils.isPolicyExpenseChat(report) && report.ownerEmail === email && report.statusNum !== CONST.REPORT.STATUS.CLOSED);
+ const workspaceChatReport = _.find(
+ allReports,
+ (report) => ReportUtils.isPolicyExpenseChat(report) && report.ownerAccountID === currentUserAccountID && report.statusNum !== CONST.REPORT.STATUS.CLOSED,
+ );
if (workspaceChatReport && !isDisplayingWorkspaceRoute) {
// This key is only updated when we call ReconnectApp, setting it to false now allows the user to navigate normally instead of always redirecting to the workspace chat
Onyx.set(ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER, false);
diff --git a/src/pages/iouReportPropTypes.js b/src/pages/iouReportPropTypes.js
index d6481cb1e871..284f0915dbbc 100644
--- a/src/pages/iouReportPropTypes.js
+++ b/src/pages/iouReportPropTypes.js
@@ -11,7 +11,7 @@ export default PropTypes.shape({
total: PropTypes.number,
/** The owner of the IOUReport */
- ownerEmail: PropTypes.string,
+ ownerAccountID: PropTypes.number,
/** The currency of the IOUReport */
currency: PropTypes.string,
diff --git a/src/pages/reportPropTypes.js b/src/pages/reportPropTypes.js
index 4b50909032a1..f2e8578aaa38 100644
--- a/src/pages/reportPropTypes.js
+++ b/src/pages/reportPropTypes.js
@@ -50,9 +50,6 @@ export default PropTypes.shape({
/** The policy name to use for an archived report */
oldPolicyName: PropTypes.string,
- /** The email address of the report owner */
- ownerEmail: PropTypes.string,
-
/** The accountID of the report owner */
ownerAccountID: PropTypes.number,
diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js
index f12c367b0038..e0fec4bf8ef4 100644
--- a/tests/unit/OptionsListUtilsTest.js
+++ b/tests/unit/OptionsListUtilsTest.js
@@ -283,7 +283,6 @@ describe('OptionsListUtils', () => {
initialKeyStates: {
[ONYXKEYS.SESSION]: {accountID: 2, email: 'tonystark@expensify.com'},
[`${ONYXKEYS.COLLECTION.REPORT}100`]: {
- ownerEmail: 'mistersinister@marauders.com',
ownerAccountID: 8,
total: '1000',
},
diff --git a/tests/unit/ReportUtilsTest.js b/tests/unit/ReportUtilsTest.js
index f33fdc86ef77..5a0446dede65 100644
--- a/tests/unit/ReportUtilsTest.js
+++ b/tests/unit/ReportUtilsTest.js
@@ -232,7 +232,6 @@ describe('ReportUtils', () => {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
policyID: policy.policyID,
isOwnPolicyExpenseChat: true,
- ownerEmail: 'ragnar@vikings.net',
ownerAccountID: 1,
}),
).toBe('Vikings Policy');
@@ -244,7 +243,6 @@ describe('ReportUtils', () => {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
policyID: policy.policyID,
isOwnPolicyExpenseChat: false,
- ownerEmail: 'ragnar@vikings.net',
ownerAccountID: 1,
}),
).toBe('Ragnar Lothbrok');
@@ -254,7 +252,6 @@ describe('ReportUtils', () => {
describe('Archived', () => {
const baseArchivedPolicyExpenseChat = {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
- ownerEmail: 'ragnar@vikings.net',
ownerAccountID: 1,
policyID: policy.policyID,
oldPolicyName: policy.name,