Skip to content

Commit d396430

Browse files
authored
Merge pull request #20473 from Expensify/personalDetailsList-migration
Main `personalDetailsList` & `policyMembers` Onyx key migrations
2 parents 205899f + ff4df6b commit d396430

File tree

84 files changed

+1428
-959
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1428
-959
lines changed

.env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,20 @@ USE_WEB_PROXY=false
1111
USE_WDYR=false
1212
CAPTURE_METRICS=false
1313
ONYX_METRICS=false
14+
15+
EXPENSIFY_ACCOUNT_ID_ACCOUNTING=-1
16+
EXPENSIFY_ACCOUNT_ID_ADMIN=-1
17+
EXPENSIFY_ACCOUNT_ID_BILLS=-1
18+
EXPENSIFY_ACCOUNT_ID_CHRONOS=-1
19+
EXPENSIFY_ACCOUNT_ID_CONCIERGE=-1
20+
EXPENSIFY_ACCOUNT_ID_CONTRIBUTORS=-1
21+
EXPENSIFY_ACCOUNT_ID_FIRST_RESPONDER=-1
22+
EXPENSIFY_ACCOUNT_ID_HELP=-1
23+
EXPENSIFY_ACCOUNT_ID_INTEGRATION_TESTING_CREDS=-1
24+
EXPENSIFY_ACCOUNT_ID_PAYROLL=-1
25+
EXPENSIFY_ACCOUNT_ID_QA=-1
26+
EXPENSIFY_ACCOUNT_ID_QA_TRAVIS=-1
27+
EXPENSIFY_ACCOUNT_ID_RECEIPTS=-1
28+
EXPENSIFY_ACCOUNT_ID_REWARDS=-1
29+
EXPENSIFY_ACCOUNT_ID_STUDENT_AMBASSADOR=-1
30+
EXPENSIFY_ACCOUNT_ID_SVFG=-1

src/CONST.js

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ const CONST = {
619619
MAX_ROOM_NAME_LENGTH: 79,
620620
LAST_MESSAGE_TEXT_MAX_LENGTH: 200,
621621
OWNER_EMAIL_FAKE: '__FAKE__',
622+
OWNER_ACCOUNT_ID_FAKE: 0,
622623
DEFAULT_REPORT_NAME: 'Chat Report',
623624
},
624625
COMPOSER: {
@@ -862,22 +863,41 @@ const CONST = {
862863
LHN_SKELETON_VIEW_ITEM_HEIGHT: 64,
863864
EXPENSIFY_PARTNER_NAME: 'expensify.com',
864865
EMAIL: {
865-
CONCIERGE: 'concierge@expensify.com',
866-
HELP: 'help@expensify.com',
867-
RECEIPTS: 'receipts@expensify.com',
866+
ACCOUNTING: 'accounting@expensify.com',
867+
ADMIN: 'admin@expensify.com',
868+
BILLS: 'bills@expensify.com',
868869
CHRONOS: '[email protected]',
869-
QA: 'qa@expensify.com',
870+
CONCIERGE: 'concierge@expensify.com',
870871
CONTRIBUTORS: '[email protected]',
871872
FIRST_RESPONDER: '[email protected]',
873+
GUIDES_DOMAIN: 'team.expensify.com',
874+
875+
INTEGRATION_TESTING_CREDS: '[email protected]',
876+
PAYROLL: '[email protected]',
877+
872878
QA_TRAVIS: '[email protected]',
873-
BILLS: 'bills@expensify.com',
879+
RECEIPTS: 'receipts@expensify.com',
874880
STUDENT_AMBASSADOR: '[email protected]',
875-
ACCOUNTING: '[email protected]',
876-
PAYROLL: '[email protected]',
877881
878-
INTEGRATION_TESTING_CREDS: '[email protected]',
879-
880-
GUIDES_DOMAIN: 'team.expensify.com',
882+
},
883+
884+
ACCOUNT_ID: {
885+
ACCOUNTING: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_ACCOUNTING', 9645353)),
886+
ADMIN: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_ADMIN', -1)),
887+
BILLS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_BILLS', 1371)),
888+
CHRONOS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_CHRONOS', 10027416)),
889+
CONCIERGE: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_CONCIERGE', 8392101)),
890+
CONTRIBUTORS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_CONTRIBUTORS', 9675014)),
891+
FIRST_RESPONDER: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_FIRST_RESPONDER', 9375152)),
892+
HELP: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_HELP', -1)),
893+
INTEGRATION_TESTING_CREDS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_INTEGRATION_TESTING_CREDS', -1)),
894+
PAYROLL: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_PAYROLL', 9679724)),
895+
QA: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_QA', 3126513)),
896+
QA_TRAVIS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_QA_TRAVIS', 8595733)),
897+
RECEIPTS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_RECEIPTS', -1)),
898+
REWARDS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_REWARDS', 11023767)), // rewards@expensify.com
899+
STUDENT_AMBASSADOR: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_STUDENT_AMBASSADOR', 10476956)),
900+
SVFG: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_SVFG', 2012843)),
881901
},
882902

883903
ENVIRONMENT: {
@@ -1059,6 +1079,7 @@ const CONST = {
10591079
ROOM_PREFIX: '#',
10601080
CUSTOM_UNIT_RATE_BASE_OFFSET: 100,
10611081
OWNER_EMAIL_FAKE: '_FAKE_',
1082+
OWNER_ACCOUNT_ID_FAKE: 0,
10621083
},
10631084

10641085
CUSTOM_UNITS: {
@@ -1166,21 +1187,41 @@ const CONST = {
11661187
},
11671188
get EXPENSIFY_EMAILS() {
11681189
return [
1169-
this.EMAIL.CONCIERGE,
1170-
this.EMAIL.HELP,
1171-
this.EMAIL.RECEIPTS,
1190+
this.EMAIL.ACCOUNTING,
1191+
this.EMAIL.ADMIN,
1192+
this.EMAIL.BILLS,
11721193
this.EMAIL.CHRONOS,
1173-
this.EMAIL.QA,
1194+
this.EMAIL.CONCIERGE,
11741195
this.EMAIL.CONTRIBUTORS,
11751196
this.EMAIL.FIRST_RESPONDER,
1197+
this.EMAIL.HELP,
1198+
this.EMAIL.INTEGRATION_TESTING_CREDS,
1199+
this.EMAIL.PAYROLL,
1200+
this.EMAIL.QA,
11761201
this.EMAIL.QA_TRAVIS,
1177-
this.EMAIL.BILLS,
1202+
this.EMAIL.RECEIPTS,
11781203
this.EMAIL.STUDENT_AMBASSADOR,
1179-
this.EMAIL.ACCOUNTING,
1180-
this.EMAIL.PAYROLL,
11811204
this.EMAIL.SVFG,
1182-
this.EMAIL.INTEGRATION_TESTING_CREDS,
1183-
this.EMAIL.ADMIN,
1205+
];
1206+
},
1207+
get EXPENSIFY_ACCOUNT_IDS() {
1208+
return [
1209+
this.ACCOUNT_ID.ACCOUNTING,
1210+
this.ACCOUNT_ID.ADMIN,
1211+
this.ACCOUNT_ID.BILLS,
1212+
this.ACCOUNT_ID.CHRONOS,
1213+
this.ACCOUNT_ID.CONCIERGE,
1214+
this.ACCOUNT_ID.CONTRIBUTORS,
1215+
this.ACCOUNT_ID.FIRST_RESPONDER,
1216+
this.ACCOUNT_ID.HELP,
1217+
this.ACCOUNT_ID.INTEGRATION_TESTING_CREDS,
1218+
this.ACCOUNT_ID.PAYROLL,
1219+
this.ACCOUNT_ID.QA,
1220+
this.ACCOUNT_ID.QA_TRAVIS,
1221+
this.ACCOUNT_ID.RECEIPTS,
1222+
this.ACCOUNT_ID.REWARDS,
1223+
this.ACCOUNT_ID.STUDENT_AMBASSADOR,
1224+
this.ACCOUNT_ID.SVFG,
11841225
];
11851226
},
11861227

src/ONYXKEYS.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ export default {
4242
// Has information about the network status (offline/online)
4343
NETWORK: 'network',
4444

45-
// Contains all the personalDetails the user has access to
46-
PERSONAL_DETAILS: 'personalDetails',
47-
4845
// Contains all the personalDetails the user has access to, keyed by accountID
4946
PERSONAL_DETAILS_LIST: 'personalDetailsList',
5047

@@ -113,7 +110,7 @@ export default {
113110
COLLECTION: {
114111
DOWNLOAD: 'download_',
115112
POLICY: 'policy_',
116-
POLICY_MEMBER_LIST: 'policyMemberList_',
113+
POLICY_MEMBERS: 'policyMembers_',
117114
WORKSPACE_INVITE_MEMBERS_DRAFT: 'workspaceInviteMembersDraft_',
118115
REPORT: 'report_',
119116
REPORT_ACTIONS: 'reportActions_',

src/components/ArchivedReportFooter.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as ReportUtils from '../libs/ReportUtils';
1212
import reportPropTypes from '../pages/reportPropTypes';
1313
import * as ReportActionsUtils from '../libs/ReportActionsUtils';
1414
import styles from '../styles/styles';
15+
import * as PersonalDetailsUtils from '../libs/PersonalDetailsUtils';
1516

1617
const propTypes = {
1718
/** The reason this report was archived */
@@ -49,14 +50,14 @@ const defaultProps = {
4950

5051
function ArchivedReportFooter(props) {
5152
const archiveReason = lodashGet(props.reportClosedAction, 'originalMessage.reason', CONST.REPORT.ARCHIVE_REASON.DEFAULT);
52-
let displayName = lodashGet(props.personalDetails, `${props.report.ownerEmail}.displayName`, props.report.ownerEmail);
53+
let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [props.report.ownerAccountID, 'displayName'], props.report.ownerEmail);
5354

5455
let oldDisplayName;
5556
if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED) {
56-
const newLogin = props.reportClosedAction.originalMessage.newLogin;
57-
const oldLogin = props.reportClosedAction.originalMessage.oldLogin;
58-
displayName = lodashGet(props.personalDetails, `${newLogin}.displayName`, newLogin);
59-
oldDisplayName = lodashGet(props.personalDetails, `${oldLogin}.displayName`, oldLogin);
57+
const newAccountID = props.reportClosedAction.originalMessage.newAccountID;
58+
const oldAccountID = props.reportClosedAction.originalMessage.oldAccountID;
59+
displayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [newAccountID, 'displayName']);
60+
oldDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [oldAccountID, 'displayName']);
6061
}
6162

6263
return (
@@ -81,7 +82,7 @@ export default compose(
8182
withLocalize,
8283
withOnyx({
8384
personalDetails: {
84-
key: ONYXKEYS.PERSONAL_DETAILS,
85+
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
8586
},
8687
reportClosedAction: {
8788
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`,

src/components/AvatarWithDisplayName.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ const defaultProps = {
5050
};
5151

5252
function AvatarWithDisplayName(props) {
53-
const title = props.isAnonymous ? props.report.displayName : ReportUtils.getDisplayNameForParticipant(props.report.ownerEmail, true);
53+
const title = props.isAnonymous ? props.report.displayName : ReportUtils.getDisplayNameForParticipant(props.report.ownerAccountID, true);
5454
const subtitle = ReportUtils.getChatRoomSubtitle(props.report);
5555
const isExpenseReport = ReportUtils.isExpenseReport(props.report);
5656
const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies);
57-
const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForLogins([props.report.ownerEmail], props.personalDetails);
58-
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(ownerPersonalDetails, false);
57+
const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs([props.report.ownerAccountID], props.personalDetails);
58+
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(_.values(ownerPersonalDetails), false);
5959
const avatarContainerStyle = StyleUtils.getEmptyAvatarStyle(props.size) || styles.emptyAvatar;
6060
return (
6161
<View style={[styles.appContentHeaderTitle, styles.flex1]}>

src/components/AvatarWithIndicator.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const propTypes = {
2929
/* Onyx Props */
3030

3131
/** The employee list of all policies (coming from Onyx) */
32-
policiesMemberList: PropTypes.objectOf(policyMemberPropType),
32+
allPolicyMembers: PropTypes.objectOf(PropTypes.objectOf(policyMemberPropType)),
3333

3434
/** All the user's policies (from Onyx via withFullPolicy) */
3535
policies: PropTypes.objectOf(policyPropTypes.policy),
@@ -62,7 +62,7 @@ const propTypes = {
6262
const defaultProps = {
6363
tooltipText: '',
6464
reimbursementAccount: {},
65-
policiesMemberList: {},
65+
allPolicyMembers: {},
6666
policies: {},
6767
bankAccountList: {},
6868
cardList: {},
@@ -75,7 +75,7 @@ function AvatarWithIndicator(props) {
7575
// If a policy was just deleted from Onyx, then Onyx will pass a null value to the props, and
7676
// those should be cleaned out before doing any error checking
7777
const cleanPolicies = _.pick(props.policies, (policy) => policy);
78-
const cleanPolicyMembers = _.pick(props.policiesMemberList, (member) => member);
78+
const cleanAllPolicyMembers = _.pick(props.allPolicyMembers, (policyMembers) => policyMembers);
7979

8080
// All of the error & info-checking methods are put into an array. This is so that using _.some() will return
8181
// early as soon as the first error / info condition is returned. This makes the checks very efficient since
@@ -85,7 +85,7 @@ function AvatarWithIndicator(props) {
8585
() => PaymentMethods.hasPaymentMethodError(props.bankAccountList, props.cardList),
8686
() => _.some(cleanPolicies, PolicyUtils.hasPolicyError),
8787
() => _.some(cleanPolicies, PolicyUtils.hasCustomUnitsError),
88-
() => _.some(cleanPolicyMembers, PolicyUtils.hasPolicyMemberError),
88+
() => _.some(cleanAllPolicyMembers, PolicyUtils.hasPolicyMemberError),
8989
() => !_.isEmpty(props.reimbursementAccount.errors),
9090
() => UserUtils.hasLoginListError(props.loginList),
9191

@@ -114,8 +114,8 @@ AvatarWithIndicator.propTypes = propTypes;
114114
AvatarWithIndicator.displayName = 'AvatarWithIndicator';
115115

116116
export default withOnyx({
117-
policiesMemberList: {
118-
key: ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST,
117+
allPolicyMembers: {
118+
key: ONYXKEYS.COLLECTION.POLICY_MEMBERS,
119119
},
120120
policies: {
121121
key: ONYXKEYS.COLLECTION.POLICY,

src/components/DisplayNames/displayNamesPropTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const propTypes = {
1111
displayName: PropTypes.string,
1212

1313
/** The Account ID for the tooltip */
14-
accountID: PropTypes.string,
14+
accountID: PropTypes.number,
1515

1616
/** The login for the tooltip fallback */
1717
login: PropTypes.string,

src/components/MoneyRequestHeader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ function MoneyRequestHeader(props) {
8080
const moneyRequestReport = props.isSingleTransactionView ? props.parentReport : props.report;
8181
const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID);
8282
const isExpenseReport = ReportUtils.isExpenseReport(moneyRequestReport);
83-
const payeeName = isExpenseReport ? ReportUtils.getPolicyName(moneyRequestReport, props.policies) : ReportUtils.getDisplayNameForParticipant(moneyRequestReport.managerEmail);
83+
const payeeName = isExpenseReport ? ReportUtils.getPolicyName(moneyRequestReport, props.policies) : ReportUtils.getDisplayNameForParticipant(moneyRequestReport.managerID);
8484
const payeeAvatar = isExpenseReport
8585
? ReportUtils.getWorkspaceAvatar(moneyRequestReport)
86-
: UserUtils.getAvatar(lodashGet(props.personalDetails, [moneyRequestReport.managerEmail, 'avatar']), moneyRequestReport.managerEmail);
86+
: UserUtils.getAvatar(lodashGet(props.personalDetails, [moneyRequestReport.managerID, 'avatar']), moneyRequestReport.managerID);
8787
const policy = props.policies[`${ONYXKEYS.COLLECTION.POLICY}${props.report.policyID}`];
8888
const isPayer =
89-
Policy.isAdminOfFreePolicy([policy]) || (ReportUtils.isMoneyRequestReport(moneyRequestReport) && lodashGet(props.session, 'email', null) === moneyRequestReport.managerEmail);
89+
Policy.isAdminOfFreePolicy([policy]) || (ReportUtils.isMoneyRequestReport(moneyRequestReport) && lodashGet(props.session, 'accountID', null) === moneyRequestReport.managerID);
9090
const shouldShowSettlementButton = !isSettled && !props.isSingleTransactionView && isPayer;
9191
const bankAccountRoute = ReportUtils.getBankAccountRoute(props.chatReport);
92-
const shouldShowPaypal = Boolean(lodashGet(props.personalDetails, [moneyRequestReport.managerEmail, 'payPalMeAddress']));
92+
const shouldShowPaypal = Boolean(lodashGet(props.personalDetails, [moneyRequestReport.managerID, 'payPalMeAddress']));
9393
return (
9494
<View style={[{backgroundColor: themeColors.highlightBG}, styles.pl0]}>
9595
<HeaderWithBackButton

src/components/MultipleAvatars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function MultipleAvatars(props) {
6969
let avatarContainerStyles = props.size === CONST.AVATAR_SIZE.SMALL ? [styles.emptyAvatarSmall, styles.emptyAvatarMarginSmall] : [styles.emptyAvatar, styles.emptyAvatarMargin];
7070
const singleAvatarStyles = props.size === CONST.AVATAR_SIZE.SMALL ? styles.singleAvatarSmall : styles.singleAvatar;
7171
const secondAvatarStyles = [props.size === CONST.AVATAR_SIZE.SMALL ? styles.secondAvatarSmall : styles.secondAvatar, ...props.secondAvatarStyle];
72-
const tooltipTexts = props.shouldShowTooltip ? _.pluck(props.icons, 'name') : [];
72+
const tooltipTexts = props.shouldShowTooltip ? _.pluck(props.icons, 'name') : [''];
7373

7474
if (!props.icons.length) {
7575
return null;

src/components/OnyxProvider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ComposeProviders from './ComposeProviders';
77
// Set up any providers for individual keys. This should only be used in cases where many components will subscribe to
88
// the same key (e.g. FlatList renderItem components)
99
const [withNetwork, NetworkProvider, NetworkContext] = createOnyxContext(ONYXKEYS.NETWORK, {});
10-
const [withPersonalDetails, PersonalDetailsProvider] = createOnyxContext(ONYXKEYS.PERSONAL_DETAILS);
10+
const [withPersonalDetails, PersonalDetailsProvider] = createOnyxContext(ONYXKEYS.PERSONAL_DETAILS_LIST);
1111
const [withCurrentDate, CurrentDateProvider] = createOnyxContext(ONYXKEYS.CURRENT_DATE);
1212
const [withReportActionsDrafts, ReportActionsDraftsProvider] = createOnyxContext(ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS);
1313
const [withBlockedFromConcierge, BlockedFromConciergeProvider] = createOnyxContext(ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE);

0 commit comments

Comments
 (0)