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

Fix - Add BA thread is missing Add button, incomplete thread header and "Hidden" user #38884

Merged
2 changes: 1 addition & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function isThreadParentMessage(reportAction: OnyxEntry<ReportAction>, reportID:
*
* @deprecated Use Onyx.connect() or withOnyx() instead
*/
function getParentReportAction(report: OnyxEntry<Report> | EmptyObject): ReportAction | Record<string, never> {
function getParentReportAction(report: OnyxEntry<Report> | EmptyObject): ReportAction | EmptyObject {
if (!report?.parentReportID || !report.parentReportActionID) {
return {};
}
Expand Down
22 changes: 17 additions & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2851,6 +2851,22 @@ function getAdminRoomInvitedParticipants(parentReportAction: ReportAction | Reco
return roomName ? `${verb} ${users} ${preposition} ${roomName}` : `${verb} ${users}`;
}

/**
* Get the report action message for a report action.
*/
function getReportActionMessage(reportAction: ReportAction | EmptyObject, parentReportID?: string) {
if (isEmptyObject(reportAction)) {
return '';
}
if (ReportActionsUtils.isApprovedOrSubmittedReportAction(reportAction)) {
return ReportActionsUtils.getReportActionMessageText(reportAction);
Copy link
Contributor

Choose a reason for hiding this comment

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

This was getting the non-localized message from the backend, causing #41202 which we fixed in #41884

}
if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) {
return getReimbursementQueuedActionMessage(reportAction, getReport(parentReportID), false);
}
return reportAction?.message?.[0]?.text ?? '';
}

/**
* Get the title for a report.
*/
Expand All @@ -2871,11 +2887,7 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
}

const isAttachment = ReportActionsUtils.isReportActionAttachment(!isEmptyObject(parentReportAction) ? parentReportAction : null);
const parentReportActionMessage = (
ReportActionsUtils.isApprovedOrSubmittedReportAction(parentReportAction)
? ReportActionsUtils.getReportActionMessageText(parentReportAction)
: parentReportAction?.message?.[0]?.text ?? ''
).replace(/(\r\n|\n|\r)/gm, ' ');
const parentReportActionMessage = getReportActionMessage(parentReportAction, report?.parentReportID).replace(/(\r\n|\n|\r)/gm, ' ');
if (isAttachment && parentReportActionMessage) {
return `[${Localize.translateLocal('common.attachment')}]`;
}
Expand Down
9 changes: 5 additions & 4 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,11 @@ function ReportActionItem({
</ShowContextMenuContext.Provider>
);
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED) {
const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails[report.ownerAccountID ?? -1]);
const linkedReport = ReportUtils.isChatThread(report) ? ReportUtils.getReport(report.parentReportID) : report;
const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails[linkedReport?.ownerAccountID ?? -1]);
const paymentType = action.originalMessage.paymentType ?? '';

const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, report.reportID, action);
const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, linkedReport?.reportID ?? '', action);
children = (
<ReportActionItemBasicMessage
message={translate(paymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY ? 'iou.waitingOnEnabledWallet' : 'iou.waitingOnBankAccount', {submitterDisplayName})}
Expand All @@ -494,7 +495,7 @@ function ReportActionItem({
success
style={[styles.w100, styles.requestPreviewBox]}
text={translate('bankAccount.addBankAccount')}
onPress={() => BankAccounts.openPersonalBankAccountSetupView(report.reportID)}
onPress={() => BankAccounts.openPersonalBankAccountSetupView(Navigation.getTopmostReportId() ?? linkedReport?.reportID)}
pressOnEnter
large
/>
Expand All @@ -505,7 +506,7 @@ function ReportActionItem({
enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS}
addBankAccountRoute={ROUTES.BANK_ACCOUNT_PERSONAL}
addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD}
chatReportID={report.reportID}
chatReportID={linkedReport?.reportID}
iouReport={iouReport}
>
{(triggerKYCFlow, buttonRef) => (
Expand Down
Loading