Skip to content
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
12 changes: 11 additions & 1 deletion src/libs/IOUAmountSubmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,17 @@ function buildReportParticipants(args: SubmitAmountArgs) {
const privateIsArchived = !!allReportNVPs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`]?.private_isArchived;
return participantAccountID
? getParticipantsOption(participant, allPersonalDetails, translate)
: getReportOption(participant, privateIsArchived, policy, allPersonalDetails, conciergeReportID, reportAttributesReports, reportDraft, currentUserPersonalDetails.accountID);
: getReportOption(
participant,
privateIsArchived,
policy,
allPersonalDetails,
conciergeReportID,
reportAttributesReports,
reportDraft,
currentUserPersonalDetails.accountID,
translate,
);
});
}

Expand Down
32 changes: 17 additions & 15 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1270,8 +1270,8 @@ function getReportOption(
reportAttributesDerived: ReportAttributesDerivedValue['reports'] | undefined,
reportDraft: OnyxEntry<Report>,
currentUserAccountID: number,
translate: LocalizedTranslate,
policyTags?: OnyxCollection<PolicyTagLists>,
visibleReportActionsData: VisibleReportActionsDerivedValue = {},
): OptionData {
const report = getReportOrDraftReport(participant.reportID, undefined, undefined, reportDraft);
const visibleParticipantAccountIDs = getParticipantsAccountIDsForDisplay(report, true);
Expand All @@ -1289,28 +1289,28 @@ function getReportOption(
},
reportAttributesDerived,
policyTags: reportPolicyTags,
visibleReportActionsData,
visibleReportActionsData: {},
conciergeReportID,
currentUserAccountID,
});

// Update text & alternateText because createOption returns workspace name only if report is owned by the user
if (option.isSelfDM) {
option.alternateText = translateLocal('reportActionsView.yourSpace');
option.alternateText = translate('reportActionsView.yourSpace');
} else if (option.isInvoiceRoom) {
option.text = deprecatedGetReportName(report, reportAttributesDerived);
option.alternateText = translateLocal('workspace.common.invoices');
option.alternateText = translate('workspace.common.invoices');
} else {
option.text = getPolicyName({report, policy});
option.alternateText = translateLocal('workspace.common.workspace');
option.text = getPolicyName({report, policy, unavailableTranslation: translate('workspace.common.unavailable')});
option.alternateText = translate('workspace.common.workspace');

if (report?.policyID) {
const submitToAccountID = getSubmitToAccountID(policy, report, getLoginByAccountID(report?.ownerAccountID, personalDetails));
const submitsToAccountDetails = personalDetails?.[submitToAccountID];
const subtitle = submitsToAccountDetails?.displayName ?? submitsToAccountDetails?.login;

if (subtitle) {
option.alternateText = translateLocal('iou.submitsTo', subtitle ?? '');
option.alternateText = translate('iou.submitsTo', subtitle ?? '');
}
}
}
Expand All @@ -1330,6 +1330,7 @@ function getReportDisplayOption(
personalDetails: OnyxEntry<PersonalDetailsList>,
privateIsArchived: boolean | undefined,
policy: OnyxEntry<Policy>,
translate: LocalizedTranslate,
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
policyTags?: OnyxEntry<PolicyTagLists>,
visibleReportActionsData: VisibleReportActionsDerivedValue = {},
Expand All @@ -1353,17 +1354,17 @@ function getReportDisplayOption(

// Update text & alternateText because createOption returns workspace name only if report is owned by the user
if (option.isSelfDM) {
option.alternateText = translateLocal('reportActionsView.yourSpace');
option.alternateText = translate('reportActionsView.yourSpace');
} else if (option.isInvoiceRoom) {
option.text = deprecatedGetReportName(report, reportAttributesDerived);
option.alternateText = translateLocal('workspace.common.invoices');
option.alternateText = translate('workspace.common.invoices');
} else if (unknownUserDetails) {
option.text = unknownUserDetails.text ?? unknownUserDetails.login;
option.alternateText = unknownUserDetails.login;
option.participantsList = [{...unknownUserDetails, displayName: unknownUserDetails.login, accountID: unknownUserDetails.accountID ?? CONST.DEFAULT_NUMBER_ID}];
} else if (report?.ownerAccountID !== 0 || !option.text) {
option.text = getPolicyName({report, policy});
option.alternateText = translateLocal('workspace.common.workspace');
option.text = getPolicyName({report, policy, unavailableTranslation: translate('workspace.common.unavailable')});
option.alternateText = translate('workspace.common.workspace');
}
option.isDisabled = true;
option.isSelected = false;
Expand All @@ -1380,6 +1381,7 @@ function getPolicyExpenseReportOption(
personalDetails: OnyxEntry<PersonalDetailsList>,
expenseReport: OnyxEntry<Report>,
policy: OnyxEntry<Policy>,
translate: LocalizedTranslate,
reportAttributesDerived?: ReportAttributesDerivedValue['reports'],
policyTags?: OnyxEntry<PolicyTagLists>,
visibleReportActionsData: VisibleReportActionsDerivedValue = {},
Expand All @@ -1404,8 +1406,8 @@ function getPolicyExpenseReportOption(
});

// Update text & alternateText because createOption returns workspace name only if report is owned by the user
option.text = getPolicyName({report: expenseReport, policy});
option.alternateText = translateLocal('workspace.common.workspace');
option.text = getPolicyName({report: expenseReport, policy, unavailableTranslation: translate('workspace.common.unavailable')});
option.alternateText = translate('workspace.common.workspace');
option.isSelected = participant.selected;
option.selected = participant.selected; // Keep for backwards compatibility
return option;
Expand Down Expand Up @@ -3160,7 +3162,7 @@ function formatSectionsFromSearchTerm(
const expenseReport = getReportByID(participant.reportID);
const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${expenseReport?.reportID}`];
const expenseReportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${expenseReport?.policyID}`];
return getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, expenseReport, expenseReportPolicy, reportAttributesDerived);
return getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, expenseReport, expenseReportPolicy, translate, reportAttributesDerived);
}
return getParticipantsOption(participant, personalDetails, translate);
})
Expand Down Expand Up @@ -3192,7 +3194,7 @@ function formatSectionsFromSearchTerm(
const expenseReport = getReportByID(participant.reportID);
const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${expenseReport?.reportID}`];
const expenseReportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${expenseReport?.policyID}`];
return getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, expenseReport, expenseReportPolicy, reportAttributesDerived);
return getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, expenseReport, expenseReportPolicy, translate, reportAttributesDerived);
}
return getParticipantsOption(participant, personalDetails, translate);
})
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/IOU/MoneyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ function getMoneyRequestParticipantOptions(
const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID;
return participantAccountID
? getParticipantsOption(participant, personalDetails, translate)
: getReportOption(participant, privateIsArchived, policy, personalDetails, conciergeReportID, reportAttributesDerived, reportDraft, currentUserAccountID);
: getReportOption(participant, privateIsArchived, policy, personalDetails, conciergeReportID, reportAttributesDerived, reportDraft, currentUserAccountID, translate);
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/pages/Share/ShareDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ function ShareDetailsPage({route}: ShareDetailsPageProps) {
const ancestors = useAncestors(report);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`);
const displayReport = useMemo(
() => getReportDisplayOption(report, unknownUserDetails, personalDetails, privateIsArchived, policy, reportAttributesDerived),
[report, unknownUserDetails, personalDetails, privateIsArchived, reportAttributesDerived, policy],
() => getReportDisplayOption(report, unknownUserDetails, personalDetails, privateIsArchived, policy, translate, reportAttributesDerived),
[report, unknownUserDetails, personalDetails, privateIsArchived, reportAttributesDerived, policy, translate],
);

const shouldShowAttachment = !isTextShared;
Expand Down
12 changes: 11 additions & 1 deletion src/pages/Share/SubmitDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,17 @@ function SubmitDetailsPage({
const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`];
return participant?.accountID
? getParticipantsOption(participant, personalDetails, translate)
: getReportOption(participant, privateIsArchived, policy, personalDetails, conciergeReportID, reportAttributesDerived, reportDraft, currentUserPersonalDetails.accountID);
: getReportOption(
participant,
privateIsArchived,
policy,
personalDetails,
conciergeReportID,
reportAttributesDerived,
reportDraft,
currentUserPersonalDetails.accountID,
translate,
);
});

const isPolicyExpenseChat = participants?.some((participant) => participant.isPolicyExpenseChat);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/DynamicSplitBillDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPag
if (isPolicyExpenseChat(report)) {
participants = [
getParticipantsOption({accountID: participantAccountIDs.at(0), selected: true, reportID: ''}, personalDetails, translate),
getPolicyExpenseReportOption({...report, selected: true, reportID}, privateIsArchived, personalDetails, report, policy, reportAttributesDerived),
getPolicyExpenseReportOption({...report, selected: true, reportID}, privateIsArchived, personalDetails, report, policy, translate, reportAttributesDerived),
];
} else {
participants = participantAccountIDs.map((accountID) => getParticipantsOption({accountID, selected: true, reportID: ''}, personalDetails, translate));
Expand Down
10 changes: 9 additions & 1 deletion src/pages/iou/request/MoneyRequestAttendeeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,15 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde
const isPolicyExpenseChat = participant?.isPolicyExpenseChat ?? false;
const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${userToInviteExpenseReport?.reportID}`];
return isPolicyExpenseChat
? getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, userToInviteExpenseReport, userToInviteExpenseReportPolicy, reportAttributesDerived)
? getPolicyExpenseReportOption(
participant,
privateIsArchived,
personalDetails,
userToInviteExpenseReport,
userToInviteExpenseReportPolicy,
translate,
reportAttributesDerived,
)
: getParticipantsOption(participant, personalDetails, translate);
}) as OptionData[],
sectionIndex: 3,
Expand Down
10 changes: 9 additions & 1 deletion src/pages/iou/request/ParticipantSearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,15 @@ function ParticipantSearchResults({
const isPolicyExpenseChat = participant?.isPolicyExpenseChat ?? false;
const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${userToInviteExpenseReport?.reportID}`];
return isPolicyExpenseChat
? getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, userToInviteExpenseReport, userToInviteExpenseReportPolicy, reportAttributesDerived)
? getPolicyExpenseReportOption(
participant,
privateIsArchived,
personalDetails,
userToInviteExpenseReport,
userToInviteExpenseReportPolicy,
translate,
reportAttributesDerived,
)
: getParticipantsOption(participant, personalDetails, translate);
}),
sectionIndex: 5,
Expand Down
12 changes: 11 additions & 1 deletion src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,17 @@ function IOURequestStepAmount({
const privateIsArchived = !!allReportNVPs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`]?.private_isArchived;
return participantAccountID
? getParticipantsOption(participant, personalDetails, translate)
: getReportOption(participant, privateIsArchived, policy, personalDetails, conciergeReportID, reportAttributesDerived, reportDraft, currentUserPersonalDetails.accountID);
: getReportOption(
participant,
privateIsArchived,
policy,
personalDetails,
conciergeReportID,
reportAttributesDerived,
reportDraft,
currentUserPersonalDetails.accountID,
translate,
);
});
const participant = participants.at(0);
const policyTags = useMoneyRequestPolicyTags({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ function IOURequestStepConfirmation({
reportAttributesDerived,
participantReportDraft,
currentUserPersonalDetails.accountID,
translate,
);
}) ?? [],
[
Expand Down
Loading
Loading