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

Display person who made the reservation instead of approver for trips #56099

Merged
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
17 changes: 9 additions & 8 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1241,8 +1241,7 @@ function isUserCreatedPolicyRoom(report: OnyxEntry<Report>): boolean {
* Whether the provided report is a Policy Expense chat.
*/
function isPolicyExpenseChat(option: OnyxInputOrEntry<Report> | OptionData | Participant): boolean {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
return getChatType(option) === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT || (option && 'isPolicyExpenseChat' in option && option.isPolicyExpenseChat) || false;
return getChatType(option) === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT || !!(option && 'isPolicyExpenseChat' in option && option.isPolicyExpenseChat);
}

function isInvoiceRoom(report: OnyxEntry<Report>): boolean {
Expand Down Expand Up @@ -8459,16 +8458,17 @@ function canLeaveChat(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>): boo
return (isChatThread(report) && !!getReportNotificationPreference(report)) || isUserCreatedPolicyRoom(report) || isNonAdminOrOwnerOfPolicyExpenseChat(report, policy);
}

function getReportActionActorAccountID(
reportAction: OnyxInputOrEntry<ReportAction>,
iouReport: OnyxInputOrEntry<Report> | undefined,
report: OnyxInputOrEntry<Report> | undefined,
): number | undefined {
function getReportActionActorAccountID(reportAction: OnyxEntry<ReportAction>, iouReport: OnyxEntry<Report>, report: OnyxEntry<Report>): number | undefined {
switch (reportAction?.actionName) {
case CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW: {
const ownerAccountID = iouReport?.ownerAccountID ?? reportAction?.childOwnerAccountID;
const actorAccountID = iouReport?.managerID ?? reportAction?.childManagerAccountID;
return isPolicyExpenseChat(report) ? ownerAccountID : actorAccountID;
Copy link
Contributor

Choose a reason for hiding this comment

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

@blazejkustra Why this change was necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't, do you think I should revert this change?


if (isPolicyExpenseChat(report)) {
return ownerAccountID;
}

return actorAccountID;
}

case CONST.REPORT.ACTIONS.TYPE.SUBMITTED:
Expand All @@ -8478,6 +8478,7 @@ function getReportActionActorAccountID(
return reportAction?.actorAccountID;
}
}

function createDraftWorkspaceAndNavigateToConfirmationScreen(transactionID: string, actionName: IOUAction): void {
const isCategorizing = actionName === CONST.IOU.ACTION.CATEGORIZE;
const {expenseChatReportID, policyID, policyName} = createDraftWorkspace();
Expand Down
6 changes: 4 additions & 2 deletions src/pages/home/report/ReportActionItemSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ function ReportActionItemSingle({
avatarId = delegatePersonalDetails?.accountID;
} else if (isReportPreviewAction && isTripRoom) {
displayName = report?.reportName ?? '';
avatarSource = personalDetails?.[ownerAccountID ?? CONST.DEFAULT_NUMBER_ID]?.avatar;
avatarId = ownerAccountID;
}

// If this is a report preview, display names and avatars of both people involved
Expand Down Expand Up @@ -210,9 +212,9 @@ function ReportActionItemSingle({
Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(iouReportID, Navigation.getReportRHPActiveRoute()));
return;
}
showUserDetails(action?.delegateAccountID ? action.delegateAccountID : actorAccountID);
showUserDetails(Number(icon.id));
}
}, [isWorkspaceActor, reportID, actorAccountID, action?.delegateAccountID, iouReportID, displayAllActors]);
}, [isWorkspaceActor, reportID, iouReportID, displayAllActors, icon.id]);

const shouldDisableDetailPage = useMemo(
() =>
Expand Down