Skip to content

Commit

Permalink
Merge pull request #22081 from Expensify/report-manageremail-migration
Browse files Browse the repository at this point in the history
Remove all uses of `report.managerEmail`
  • Loading branch information
Hayata Suenaga authored Jul 10, 2023
2 parents 401b459 + 7f51a8d commit f889c42
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
3 changes: 0 additions & 3 deletions src/components/ReportActionItem/IOUPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ const propTypes = {

/** Active IOU Report for current report */
iouReport: PropTypes.shape({
/** Email address of the manager in this iou report */
managerEmail: PropTypes.string,

/** Account ID of the manager in this iou report */
managerID: PropTypes.number,

Expand Down
18 changes: 8 additions & 10 deletions src/components/ReportActionItem/ReportPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const propTypes = {

/** Active IOU Report for current report */
iouReport: PropTypes.shape({
/** Email address of the manager in this iou report */
managerEmail: PropTypes.string,
/** AccountID of the manager in this iou report */
managerID: PropTypes.number,

/** AccountID of the creator of this iou report */
ownerAccountID: PropTypes.number,
Expand All @@ -62,8 +62,8 @@ const propTypes = {

/** Session info for the currently logged in user. */
session: PropTypes.shape({
/** Currently logged in user email */
email: PropTypes.string,
/** Currently logged in user accountID */
accountID: PropTypes.number,
}),

/** Popover context menu anchor, used for showing context menu */
Expand All @@ -81,17 +81,15 @@ const defaultProps = {
iouReport: {},
checkIfContextMenuActive: () => {},
session: {
email: null,
accountID: null,
},
};

function ReportPreview(props) {
const managerID = props.iouReport.managerID || 0;
const isCurrentUserManager = managerID === lodashGet(props.session, 'accountID');
const reportAmount = CurrencyUtils.convertToDisplayString(ReportUtils.getMoneyRequestTotal(props.iouReport), props.iouReport.currency);
const managerEmail = props.iouReport.managerEmail || '';
const managerAccountID = props.iouReport.managerID || 0;
const managerName =
(ReportUtils.isPolicyExpenseChat(props.chatReport) ? ReportUtils.getPolicyName(props.chatReport) : ReportUtils.getDisplayNameForParticipant(managerAccountID, true)) || managerEmail;
const isCurrentUserManager = managerEmail === lodashGet(props.session, 'email', null);
const managerName = ReportUtils.isPolicyExpenseChat(props.chatReport) ? ReportUtils.getPolicyName(props.chatReport) : ReportUtils.getDisplayNameForParticipant(managerID, true);
const bankAccountRoute = ReportUtils.getBankAccountRoute(props.chatReport);
return (
<View style={styles.chatItemMessage}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/TaskAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const propTypes = {
/** Title of the task */
reportName: PropTypes.string,

/** Email address of the manager in this iou report */
managerEmail: PropTypes.string,
/** AccountID of the manager in this iou report */
managerID: PropTypes.number,

/** AccountID of the creator of this iou report */
ownerAccountID: PropTypes.number,
Expand Down
4 changes: 2 additions & 2 deletions src/components/ReportActionItem/TaskPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const propTypes = {
/** Title of the task */
reportName: PropTypes.string,

/** Email address of the manager in this iou report */
managerEmail: PropTypes.string,
/** AccountID of the manager in this iou report */
managerID: PropTypes.number,

/** AccountID of the creator of this iou report */
ownerAccountID: PropTypes.number,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/IOUUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {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)}
* For example: if user1 owes user2 $10, then we have: {ownerAccountID: user2, managerID: user1, total: $10 (a positive amount, owed to user2)}
* If user1 requests $17 from user2, then we have: {ownerAccountID: user1, managerID: user2, total: $7 (still a positive amount, but now owed to user1)}
*
* @param {Object} iouReport
* @param {Number} actorAccountID
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function isCompletedTaskReport(report) {
}

function isTaskAssignee(report) {
return lodashGet(report, 'managerEmail') === currentUserEmail;
return lodashGet(report, 'managerID') === currentUserAccountID;
}

/**
Expand Down

0 comments on commit f889c42

Please sign in to comment.