Skip to content

Commit

Permalink
Merge pull request #20328 from Expensify/beaman-continueMigration
Browse files Browse the repository at this point in the history
Continue `personalDetails` -> `personalDetailsList` migration
  • Loading branch information
neil-marcellini authored Jun 8, 2023
2 parents 5a8eb95 + 79cca49 commit 1762fbe
Show file tree
Hide file tree
Showing 71 changed files with 1,039 additions and 709 deletions.
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@ USE_WEB_PROXY=false
USE_WDYR=false
CAPTURE_METRICS=false
ONYX_METRICS=false

EXPENSIFY_ACCOUNT_ID_ACCOUNTING=-1
EXPENSIFY_ACCOUNT_ID_ADMIN=-1
EXPENSIFY_ACCOUNT_ID_BILLS=-1
EXPENSIFY_ACCOUNT_ID_CHRONOS=-1
EXPENSIFY_ACCOUNT_ID_CONCIERGE=-1
EXPENSIFY_ACCOUNT_ID_CONTRIBUTORS=-1
EXPENSIFY_ACCOUNT_ID_FIRST_RESPONDER=-1
EXPENSIFY_ACCOUNT_ID_HELP=-1
EXPENSIFY_ACCOUNT_ID_INTEGRATION_TESTING_CREDS=-1
EXPENSIFY_ACCOUNT_ID_PAYROLL=-1
EXPENSIFY_ACCOUNT_ID_QA=-1
EXPENSIFY_ACCOUNT_ID_QA_TRAVIS=-1
EXPENSIFY_ACCOUNT_ID_RECEIPTS=-1
EXPENSIFY_ACCOUNT_ID_REWARDS=-1
EXPENSIFY_ACCOUNT_ID_STUDENT_AMBASSADOR=-1
EXPENSIFY_ACCOUNT_ID_SVFG=-1
79 changes: 60 additions & 19 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,22 +860,43 @@ const CONST = {
LHN_SKELETON_VIEW_ITEM_HEIGHT: 64,
EXPENSIFY_PARTNER_NAME: 'expensify.com',
EMAIL: {
CONCIERGE: 'concierge@expensify.com',
HELP: 'help@expensify.com',
RECEIPTS: 'receipts@expensify.com',
ACCOUNTING: 'accounting@expensify.com',
ADMIN: 'admin@expensify.com',
BILLS: 'bills@expensify.com',
CHRONOS: '[email protected]',
QA: 'qa@expensify.com',
CONCIERGE: 'concierge@expensify.com',
CONTRIBUTORS: '[email protected]',
FIRST_RESPONDER: '[email protected]',
GUIDES_DOMAIN: 'team.expensify.com',
HELP: '[email protected]',
INTEGRATION_TESTING_CREDS: '[email protected]',
PAYROLL: '[email protected]',
QA: '[email protected]',
QA_TRAVIS: '[email protected]',
BILLS: 'bills@expensify.com',
RECEIPTS: 'receipts@expensify.com',
STUDENT_AMBASSADOR: '[email protected]',
ACCOUNTING: '[email protected]',
PAYROLL: '[email protected]',
SVFG: '[email protected]',
INTEGRATION_TESTING_CREDS: '[email protected]',
ADMIN: '[email protected]',
GUIDES_DOMAIN: 'team.expensify.com',
},

ACCOUNT_ID: {
ACCOUNTING: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_ACCOUNTING', 9645353)),
ADMIN: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_ADMIN', -1)),
BILLS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_BILLS', 1371)),
CHRONOS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_CHRONOS', 10027416)),
CONCIERGE: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_CONCIERGE', 8392101)),
CONTRIBUTORS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_CONTRIBUTORS', 9675014)),
FIRST_RESPONDER: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_FIRST_RESPONDER', 9375152)),
HELP: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_HELP', -1)),
INTEGRATION_TESTING_CREDS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_INTEGRATION_TESTING_CREDS', -1)),
PAYROLL: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_PAYROLL', 9679724)),
QA: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_QA', 3126513)),
QA_TRAVIS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_QA_TRAVIS', 8595733)),
RECEIPTS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_RECEIPTS', -1)),
REWARDS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_REWARDS', 11023767)), // [email protected]
STUDENT_AMBASSADOR: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_STUDENT_AMBASSADOR', 10476956)),
SVFG: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_SVFG', 2012843)),
// TODO: maybe make separate domain email things??
// GUIDES_DOMAIN: ,
},

ENVIRONMENT: {
Expand Down Expand Up @@ -1164,21 +1185,41 @@ const CONST = {
},
get EXPENSIFY_EMAILS() {
return [
this.EMAIL.CONCIERGE,
this.EMAIL.HELP,
this.EMAIL.RECEIPTS,
this.EMAIL.ACCOUNTING,
this.EMAIL.ADMIN,
this.EMAIL.BILLS,
this.EMAIL.CHRONOS,
this.EMAIL.QA,
this.EMAIL.CONCIERGE,
this.EMAIL.CONTRIBUTORS,
this.EMAIL.FIRST_RESPONDER,
this.EMAIL.HELP,
this.EMAIL.INTEGRATION_TESTING_CREDS,
this.EMAIL.PAYROLL,
this.EMAIL.QA,
this.EMAIL.QA_TRAVIS,
this.EMAIL.BILLS,
this.EMAIL.RECEIPTS,
this.EMAIL.STUDENT_AMBASSADOR,
this.EMAIL.ACCOUNTING,
this.EMAIL.PAYROLL,
this.EMAIL.SVFG,
this.EMAIL.INTEGRATION_TESTING_CREDS,
this.EMAIL.ADMIN,
];
},
get EXPENSIFY_ACCOUNT_IDS() {
return [
this.ACCOUNT_ID.ACCOUNTING,
this.ACCOUNT_ID.ADMIN,
this.ACCOUNT_ID.BILLS,
this.ACCOUNT_ID.CHRONOS,
this.ACCOUNT_ID.CONCIERGE,
this.ACCOUNT_ID.CONTRIBUTORS,
this.ACCOUNT_ID.FIRST_RESPONDER,
this.ACCOUNT_ID.HELP,
this.ACCOUNT_ID.INTEGRATION_TESTING_CREDS,
this.ACCOUNT_ID.PAYROLL,
this.ACCOUNT_ID.QA,
this.ACCOUNT_ID.QA_TRAVIS,
this.ACCOUNT_ID.RECEIPTS,
this.ACCOUNT_ID.REWARDS,
this.ACCOUNT_ID.STUDENT_AMBASSADOR,
this.ACCOUNT_ID.SVFG,
];
},

Expand Down
4 changes: 1 addition & 3 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ export default {
// Has information about the network status (offline/online)
NETWORK: 'network',

// Contains all the personalDetails the user has access to
PERSONAL_DETAILS: 'personalDetails',

// Contains all the personalDetails the user has access to, keyed by accountID
PERSONAL_DETAILS_LIST: 'personalDetailsList',

Expand Down Expand Up @@ -114,6 +111,7 @@ export default {
DOWNLOAD: 'download_',
POLICY: 'policy_',
POLICY_MEMBER_LIST: 'policyMemberList_',
POLICY_MEMBERS: 'policyMembers_',
WORKSPACE_INVITE_MEMBERS_DRAFT: 'workspaceInviteMembersDraft_',
REPORT: 'report_',
REPORT_ACTIONS: 'reportActions_',
Expand Down
15 changes: 9 additions & 6 deletions src/components/ArchivedReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as ReportUtils from '../libs/ReportUtils';
import reportPropTypes from '../pages/reportPropTypes';
import * as ReportActionsUtils from '../libs/ReportActionsUtils';
import styles from '../styles/styles';
import * as PersonalDetailsUtils from '../libs/PersonalDetailsUtils';

const propTypes = {
/** The reason this report was archived */
Expand Down Expand Up @@ -49,14 +50,16 @@ const defaultProps = {

const ArchivedReportFooter = (props) => {
const archiveReason = lodashGet(props.reportClosedAction, 'originalMessage.reason', CONST.REPORT.ARCHIVE_REASON.DEFAULT);
let displayName = lodashGet(props.personalDetails, `${props.report.ownerEmail}.displayName`, props.report.ownerEmail);
let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(
props.personalDetails, [props.report.ownerAccountID, 'displayName'], props.report.ownerEmail,
);

let oldDisplayName;
if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED) {
const newLogin = props.reportClosedAction.originalMessage.newLogin;
const oldLogin = props.reportClosedAction.originalMessage.oldLogin;
displayName = lodashGet(props.personalDetails, `${newLogin}.displayName`, newLogin);
oldDisplayName = lodashGet(props.personalDetails, `${oldLogin}.displayName`, oldLogin);
const newAccountID = props.reportClosedAction.originalMessage.newAccountID;
const oldAccountID = props.reportClosedAction.originalMessage.oldAccountID;
displayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [newAccountID, 'displayName']);
oldDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [oldAccountID, 'displayName']);
}

return (
Expand All @@ -81,7 +84,7 @@ export default compose(
withLocalize,
withOnyx({
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
reportClosedAction: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`,
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarWithDisplayName.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const AvatarWithDisplayName = (props) => {
const subtitle = ReportUtils.getChatRoomSubtitle(props.report);
const isExpenseReport = ReportUtils.isExpenseReport(props.report);
const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies);
const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForLogins([props.report.ownerEmail], props.personalDetails);
const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs([props.report.ownerAccountID], props.personalDetails);
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(ownerPersonalDetails, false);
const avatarContainerStyle = StyleUtils.getEmptyAvatarStyle(props.size) || styles.emptyAvatar;
return (
Expand Down
12 changes: 6 additions & 6 deletions src/components/AvatarWithIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const propTypes = {
/* Onyx Props */

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

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

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

Expand Down Expand Up @@ -114,8 +114,8 @@ AvatarWithIndicator.propTypes = propTypes;
AvatarWithIndicator.displayName = 'AvatarWithIndicator';

export default withOnyx({
policiesMemberList: {
key: ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST,
allPolicyMembers: {
key: ONYXKEYS.COLLECTION.POLICY_MEMBERS,
},
policies: {
key: ONYXKEYS.COLLECTION.POLICY,
Expand Down
8 changes: 4 additions & 4 deletions src/components/MoneyRequestHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ const MoneyRequestHeader = (props) => {
const moneyRequestReport = props.isSingleTransactionView ? props.parentReport : props.report;
const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID);
const isExpenseReport = ReportUtils.isExpenseReport(moneyRequestReport);
const payeeName = isExpenseReport ? ReportUtils.getPolicyName(moneyRequestReport, props.policies) : ReportUtils.getDisplayNameForParticipant(moneyRequestReport.managerEmail);
const payeeName = isExpenseReport ? ReportUtils.getPolicyName(moneyRequestReport, props.policies) : ReportUtils.getDisplayNameForParticipant(moneyRequestReport.managerID);
const payeeAvatar = isExpenseReport
? ReportUtils.getWorkspaceAvatar(moneyRequestReport)
: UserUtils.getAvatar(lodashGet(props.personalDetails, [moneyRequestReport.managerEmail, 'avatar']), moneyRequestReport.managerEmail);
: UserUtils.getAvatar(lodashGet(props.personalDetails, [moneyRequestReport.managerID, 'avatar']), moneyRequestReport.managerID);
const policy = props.policies[`${ONYXKEYS.COLLECTION.POLICY}${props.report.policyID}`];
const isPayer =
Policy.isAdminOfFreePolicy([policy]) || (ReportUtils.isMoneyRequestReport(moneyRequestReport) && lodashGet(props.session, 'email', null) === moneyRequestReport.managerEmail);
Policy.isAdminOfFreePolicy([policy]) || (ReportUtils.isMoneyRequestReport(moneyRequestReport) && lodashGet(props.session, 'accountID', null) === moneyRequestReport.managerID);
const shouldShowSettlementButton = !isSettled && !props.isSingleTransactionView && isPayer;
const bankAccountRoute = ReportUtils.getBankAccountRoute(props.chatReport);
const shouldShowPaypal = Boolean(lodashGet(props.personalDetails, [moneyRequestReport.managerEmail, 'payPalMeAddress']));
const shouldShowPaypal = Boolean(lodashGet(props.personalDetails, [moneyRequestReport.managerID, 'payPalMeAddress']));
return (
<View style={[{backgroundColor: themeColors.highlightBG}, styles.pl0]}>
<HeaderWithBackButton
Expand Down
2 changes: 1 addition & 1 deletion src/components/OnyxProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ComposeProviders from './ComposeProviders';
// Set up any providers for individual keys. This should only be used in cases where many components will subscribe to
// the same key (e.g. FlatList renderItem components)
const [withNetwork, NetworkProvider, NetworkContext] = createOnyxContext(ONYXKEYS.NETWORK, {});
const [withPersonalDetails, PersonalDetailsProvider] = createOnyxContext(ONYXKEYS.PERSONAL_DETAILS);
const [withPersonalDetails, PersonalDetailsProvider] = createOnyxContext(ONYXKEYS.PERSONAL_DETAILS_LIST);
const [withCurrentDate, CurrentDateProvider] = createOnyxContext(ONYXKEYS.CURRENT_DATE);
const [withReportActionsDrafts, ReportActionsDraftsProvider] = createOnyxContext(ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS);
const [withBlockedFromConcierge, BlockedFromConciergeProvider] = createOnyxContext(ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE);
Expand Down
24 changes: 15 additions & 9 deletions src/components/ReportActionItem/IOUPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ const propTypes = {
/** Email address of the manager in this iou report */
managerEmail: PropTypes.string,

/** 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,

/** Outstanding amount in cents of this transaction */
total: PropTypes.number,

Expand Down Expand Up @@ -128,14 +134,14 @@ const IOUPreview = (props) => {
if (_.isEmpty(props.iouReport) && !props.isBillSplit) {
return null;
}
const sessionEmail = lodashGet(props.session, 'email', null);
const managerEmail = props.iouReport.managerEmail || '';
const ownerEmail = props.iouReport.ownerEmail || '';
const participantEmails = props.isBillSplit ? lodashGet(props.action, 'originalMessage.participants', []) : [managerEmail, ownerEmail];
const participantAvatars = OptionsListUtils.getAvatarsForLogins(participantEmails, props.personalDetails);
const sessionAccountID = lodashGet(props.session, 'accountID', null);
const managerID = props.iouReport.managerID || '';
const ownerAccountID = props.iouReport.ownerAccountID || '';
const participantAccountIDs = props.isBillSplit ? lodashGet(props.action, 'originalMessage.participantAccountIDs', []) : [managerID, ownerAccountID];
const participantAvatars = OptionsListUtils.getAvatarsForAccountIDs(participantAccountIDs, props.personalDetails);

// Pay button should only be visible to the manager of the report.
const isCurrentUserManager = managerEmail === sessionEmail;
const isCurrentUserManager = managerID === sessionAccountID;

const moneyRequestAction = ReportUtils.getMoneyRequestAction(props.action);

Expand Down Expand Up @@ -228,10 +234,10 @@ const IOUPreview = (props) => {
)}
{!_.isEmpty(requestComment) && <Text style={[styles.colorMuted]}>{requestComment}</Text>}
</View>
{props.isBillSplit && !_.isEmpty(participantEmails) && (
{props.isBillSplit && !_.isEmpty(participantAccountIDs) && (
<Text style={[styles.textLabel, styles.colorMuted, styles.ml1]}>
{props.translate('iou.amountEach', {
amount: CurrencyUtils.convertToDisplayString(IOUUtils.calculateAmount(participantEmails.length - 1, requestAmount), requestCurrency),
amount: CurrencyUtils.convertToDisplayString(IOUUtils.calculateAmount(participantAccountIDs.length - 1, requestAmount), requestCurrency),
})}
</Text>
)}
Expand Down Expand Up @@ -267,7 +273,7 @@ export default compose(
withLocalize,
withOnyx({
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
iouReport: {
key: ({iouReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`,
Expand Down
6 changes: 3 additions & 3 deletions src/components/ReportActionItem/MoneyRequestAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ const MoneyRequestAction = (props) => {
// If the childReportID is not present, we need to create a new thread
const childReportID = lodashGet(props.action, 'childReportID', '0');
if (childReportID === '0') {
const participants = _.uniq([props.session.email, props.action.actorEmail]);
const formattedUserLogins = _.map(participants, (login) => OptionsListUtils.addSMSDomainIfPhoneNumber(login).toLowerCase());
const participantAccountIDs = _.uniq([props.session.accountID, props.action.actorAccountID]);
const thread = ReportUtils.buildOptimisticChatReport(
formattedUserLogins,
participantAccountIDs,
props.translate(ReportActionsUtils.isSentMoneyReportAction(props.action) ? 'iou.threadSentMoneyReportName' : 'iou.threadRequestReportName', {
formattedAmount: ReportActionsUtils.getFormattedAmount(props.action),
comment: props.action.originalMessage.comment,
}),
'',
CONST.POLICY.OWNER_EMAIL_FAKE,
CONST.POLICY.OWNER_EMAIL_FAKE,
0,
false,
'',
undefined,
Expand Down
Loading

0 comments on commit 1762fbe

Please sign in to comment.