Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue personalDetails -> personalDetailsList migration #20328

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
b94183a
Remove all uses of old personalDetails onyx key
Beamanator Jun 6, 2023
7a95a3a
Use accountID to get avatars
Beamanator Jun 6, 2023
410cb62
Update to new function name
Beamanator Jun 6, 2023
7f0a66d
Migrate email to accountID where possible
Beamanator Jun 6, 2023
54ecbcb
Update a few tests with accountID-keyed details
Beamanator Jun 6, 2023
b9d30ef
Fix lots of accountID tests
Beamanator Jun 6, 2023
e5bc39b
SidebarFilterTest fixed
burczu Jun 7, 2023
d547dab
SidebarOrderTest fixed
burczu Jun 7, 2023
588cb20
JSDoc fixed
burczu Jun 7, 2023
ef3d955
fix: start migration for getSearchOptions, getOptions and createOption
BeeMargarida Jun 7, 2023
e8b7f86
Merge pull request #20351 from burczu/beaman-continueMigration-fork
Beamanator Jun 7, 2023
5c395d0
fix: complete migration of some report utils to accountID
BeeMargarida Jun 7, 2023
5f5789b
fix: generate random accountID for users info not in Onyx
BeeMargarida Jun 7, 2023
8261127
Merge branch 'beaman-continueMigration' into migration-OptionsListUtils
BeeMargarida Jun 7, 2023
f18dd6c
New util to default displayName to hidden if unavailable
Beamanator Jun 7, 2023
cf0b245
fix: update ReportUtils to use accountID and fix tests
BeeMargarida Jun 7, 2023
9d30f05
fix: add notes and fix small issues
BeeMargarida Jun 7, 2023
3ca4e0d
style: prettier
BeeMargarida Jun 7, 2023
fde3aff
Merge pull request #20371 from BeeMargarida/migration-OptionsListUtils
Beamanator Jun 7, 2023
156deff
Update a few tests
Beamanator Jun 7, 2023
fe62c42
Merge branch 'beaman-continueMigration' of github.com:Expensify/App i…
Beamanator Jun 7, 2023
9a70430
Clean up session key subscription
Beamanator Jun 7, 2023
f376593
Add new policy members key
neil-marcellini Jun 7, 2023
1d585b7
workspaces list with policy members by accountID
neil-marcellini Jun 7, 2023
c74be2c
Avatar with policy members by accountID
neil-marcellini Jun 7, 2023
0348e22
Settings page with policy members by accountID
neil-marcellini Jun 7, 2023
dda26cb
Migrate to new optionslistutil
Beamanator Jun 7, 2023
5bd48f8
Migrate to accountID & simplify
Beamanator Jun 7, 2023
60db587
withPolicy HOC members by accountID
neil-marcellini Jun 7, 2023
eae14eb
Workspace page with members by accountID
neil-marcellini Jun 7, 2023
97bf498
Merge branch 'beaman-continueMigration' into neil-collection-policy-m…
neil-marcellini Jun 7, 2023
7e77b01
Lots of accountID migrations
Beamanator Jun 7, 2023
f141c28
A few more small migrations
Beamanator Jun 7, 2023
637cce2
Merge branch 'beaman-continueMigration' into neil-collection-policy-m…
neil-marcellini Jun 7, 2023
fd201cd
Add most expensify-email accountIDs
Beamanator Jun 7, 2023
73cdf02
More migration to report participantAccountIDs
Beamanator Jun 7, 2023
60b1463
Add missing comma
Beamanator Jun 7, 2023
3d577f5
Get policy member details by accountID
neil-marcellini Jun 7, 2023
43d050a
Fix get workspace members when keyed by accountID
neil-marcellini Jun 7, 2023
083c8a8
A few more updates
Beamanator Jun 7, 2023
5204d4c
Set selected employees with members by accountIDs
neil-marcellini Jun 7, 2023
b5c20b7
Update needed hoc
Beamanator Jun 7, 2023
2eaabb8
Update personal details
Beamanator Jun 7, 2023
40aaaad
A few little fixes
Beamanator Jun 7, 2023
d580e30
Fix lint issues
Beamanator Jun 7, 2023
7f981d8
Fix report action item avatars
Beamanator Jun 7, 2023
75e0030
Remove unused var
Beamanator Jun 7, 2023
13de4af
Fix race condition
Beamanator Jun 7, 2023
a1509a8
Fix some report utils tests
Beamanator Jun 7, 2023
10176c4
A bit more updates
Beamanator Jun 7, 2023
c3497ff
Fix a few more tests
Beamanator Jun 7, 2023
651309a
Fix sidebar filter tests
Beamanator Jun 7, 2023
f141959
Create util to get emails from policy members
neil-marcellini Jun 7, 2023
6dd4a1a
Workspace invite with policy members by accountID
neil-marcellini Jun 7, 2023
bde9682
Use new util to get policy member emails
neil-marcellini Jun 7, 2023
fc38685
Map member emails to accountIDs for easy access
neil-marcellini Jun 8, 2023
8d9c4eb
Remove policy members optimistically by accountID
neil-marcellini Jun 8, 2023
e55550d
policyMembers is actually allPolicyMembers
neil-marcellini Jun 8, 2023
bac0a50
Rename to allPolicyMembers and update prop type
neil-marcellini Jun 8, 2023
ed057cc
WIP invitedEmailsToAccountIDs
neil-marcellini Jun 8, 2023
1e97491
Many iOU updates
Beamanator Jun 8, 2023
dde8e89
Merge pull request #20397 from Expensify/neil-collection-policy-members
Beamanator Jun 8, 2023
f3745b6
Merge branch 'personalDetailsList-migration' of github.com:Expensify/…
Beamanator Jun 8, 2023
b419252
Merge branch 'beaman-continueMigration' of github.com:Expensify/App i…
Beamanator Jun 8, 2023
fe3d585
More iOU updates
Beamanator Jun 8, 2023
3754886
A bit of cleanup
Beamanator Jun 8, 2023
7fe728c
Many task edits
Beamanator Jun 8, 2023
69939e8
Fix iOU test and more migration
Beamanator Jun 8, 2023
79cca49
Fix reportUtilsTest
Beamanator Jun 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 'chronos@expensify.com',
QA: 'qa@expensify.com',
CONCIERGE: 'concierge@expensify.com',
CONTRIBUTORS: 'contributors@expensify.com',
FIRST_RESPONDER: 'firstresponders@expensify.com',
GUIDES_DOMAIN: 'team.expensify.com',
HELP: 'help@expensify.com',
INTEGRATION_TESTING_CREDS: 'integrationtestingcreds@expensify.com',
PAYROLL: 'payroll@expensify.com',
QA: 'qa@expensify.com',
QA_TRAVIS: 'qa+travisreceipts@expensify.com',
BILLS: 'bills@expensify.com',
RECEIPTS: 'receipts@expensify.com',
STUDENT_AMBASSADOR: 'studentambassadors@expensify.com',
ACCOUNTING: 'accounting@expensify.com',
PAYROLL: 'payroll@expensify.com',
SVFG: 'svfg@expensify.com',
INTEGRATION_TESTING_CREDS: 'integrationtestingcreds@expensify.com',
ADMIN: 'admin@expensify.com',
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)), // rewards@expensify.com
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need this? I think yes, but it's not in CONST.EMAIL at the moment 🤷

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_',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can remove this now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite done migrating to the new key so IMO we should leave it until that's done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giggidy 👍

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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have sorted the account ids. Not doing so resulted in #31732

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
Loading