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

Remove all uses of report.managerEmail #22081

Merged
merged 7 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -41,8 +41,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 @@ -159,7 +159,7 @@ function isTaskCompleted(report) {
* @returns {Boolean}
*/
function isTaskAssignee(report) {
return lodashGet(report, 'managerEmail') === currentUserEmail;
return lodashGet(report, 'managerID') === currentUserAccountID;
}

/**
Expand Down
Loading