Skip to content

Commit

Permalink
Merge pull request #56099 from software-mansion-labs/travel/display-c…
Browse files Browse the repository at this point in the history
…orrect-member

Display person who made the reservation instead of approver for trips
  • Loading branch information
rlinoz authored Jan 31, 2025
2 parents 4459f86 + 1c5d547 commit 3cd193a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
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 @@ -8496,16 +8495,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;

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

return actorAccountID;
}

case CONST.REPORT.ACTIONS.TYPE.SUBMITTED:
Expand All @@ -8515,6 +8515,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

0 comments on commit 3cd193a

Please sign in to comment.