Skip to content

Commit

Permalink
Merge pull request #30914 from Expensify/beaman-removeFinalOwnerEmail…
Browse files Browse the repository at this point in the history
…Uses

Remove remaining uses of `report.ownerEmail`
  • Loading branch information
Beamanator authored Nov 10, 2023
2 parents 9628af9 + 493fc45 commit e220352
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/components/MoneyRequestHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction,
report={{
...report,
ownerAccountID: lodashGet(parentReport, 'ownerAccountID', null),
ownerEmail: lodashGet(parentReport, 'ownerEmail', null),
}}
policy={policy}
personalDetails={personalDetails}
Expand Down
2 changes: 0 additions & 2 deletions src/libs/E2E/apiMocks/openReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export default () => ({
reportName: 'Chat Report',
type: 'chat',
chatType: '',
ownerEmail: '__fake__',
ownerAccountID: 0,
managerEmail: '__fake__',
managerID: 0,
policyID: '_FAKE_',
participantAccountIDs: [14567013],
Expand Down
2 changes: 1 addition & 1 deletion src/libs/PersonalDetailsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Onyx.connect({
* @param {String} [defaultValue] optional default display name value
* @returns {String}
*/
function getDisplayNameOrDefault(passedPersonalDetails, pathToDisplayName, defaultValue) {
function getDisplayNameOrDefault(passedPersonalDetails, pathToDisplayName, defaultValue = '') {
const displayName = lodashGet(passedPersonalDetails, pathToDisplayName);

return displayName || defaultValue || Localize.translateLocal('common.hidden');
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function isCurrentUserSubmitter(reportID) {
return false;
}
const report = allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] || {};
return report && report.ownerEmail === currentUserEmail;
return report && report.ownerAccountID === currentUserAccountID;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -2715,10 +2715,7 @@ function submitReport(expenseReport) {
* @param {String} reimbursementBankAccountState
*/
function payMoneyRequest(paymentType, chatReport, iouReport) {
const recipient = {
login: iouReport.ownerEmail,
accountID: iouReport.ownerAccountID,
};
const recipient = {accountID: iouReport.ownerAccountID};
const {params, optimisticData, successData, failureData} = getPayMoneyRequestParams(chatReport, iouReport, recipient, paymentType);

// For now we need to call the PayMoneyRequestWithWallet API since PayMoneyRequest was not updated to work with
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ function deleteWorkspace(policyID, reports, policyName) {
// Add closed actions to all chat reports linked to this policy
..._.map(reports, ({reportID, ownerAccountID}) => {
// Announce & admin chats have FAKE owners, but workspace chats w/ users do have owners.
let reportOwnerEmail = CONST.POLICY.OWNER_EMAIL_FAKE;
let emailClosingReport = CONST.POLICY.OWNER_EMAIL_FAKE;
if (ownerAccountID !== CONST.POLICY.OWNER_ACCOUNT_ID_FAKE) {
reportOwnerEmail = lodashGet(allPersonalDetails, [ownerAccountID, 'login'], '');
emailClosingReport = lodashGet(allPersonalDetails, [ownerAccountID, 'login'], '');
}
const optimisticClosedReportAction = ReportUtils.buildOptimisticClosedReportAction(reportOwnerEmail, policyName, CONST.REPORT.ARCHIVE_REASON.POLICY_DELETED);
const optimisticClosedReportAction = ReportUtils.buildOptimisticClosedReportAction(emailClosingReport, policyName, CONST.REPORT.ARCHIVE_REASON.POLICY_DELETED);
const optimisticReportActions = {};
optimisticReportActions[optimisticClosedReportAction.reportActionID] = optimisticClosedReportAction;
return {
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,11 @@ function openReport(reportID, participantLoginList = [], newReportObject = {}, p
isOptimisticReport: true,
};

let reportOwnerEmail = CONST.REPORT.OWNER_EMAIL_FAKE;
let emailCreatingAction = CONST.REPORT.OWNER_EMAIL_FAKE;
if (newReportObject.ownerAccountID && newReportObject.ownerAccountID !== CONST.REPORT.OWNER_ACCOUNT_ID_FAKE) {
reportOwnerEmail = lodashGet(allPersonalDetails, [newReportObject.ownerAccountID, 'login'], '');
emailCreatingAction = lodashGet(allPersonalDetails, [newReportObject.ownerAccountID, 'login'], '');
}
const optimisticCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(reportOwnerEmail);
const optimisticCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(emailCreatingAction);
onyxData.optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ function ReportActionItem(props) {
</ShowContextMenuContext.Provider>
);
} else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED) {
const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails, [props.report.ownerAccountID, 'displayName'], props.report.ownerEmail);
const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails, [props.report.ownerAccountID, 'displayName']);
const paymentType = lodashGet(props.action, 'originalMessage.paymentType', '');

const isSubmitterOfUnsettledReport = ReportUtils.isCurrentUserSubmitter(props.report.reportID) && !ReportUtils.isSettled(props.report.reportID);
Expand Down
3 changes: 0 additions & 3 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ type Report = {
/** The policy name to use for an archived report */
oldPolicyName?: string;

/** The email address of the report owner */
ownerEmail?: string;

/** Linked policy's ID */
policyID?: string;

Expand Down

0 comments on commit e220352

Please sign in to comment.