Skip to content

Commit

Permalink
Merge pull request #38884 from FitseTLT/fix-add-bank-account-report-a…
Browse files Browse the repository at this point in the history
…ction-bugs

Fix - Add BA thread is missing Add button, incomplete thread header and "Hidden" user
  • Loading branch information
chiragsalian authored Apr 15, 2024
2 parents 05bdc34 + 4a27fc0 commit 159628b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,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 @@ -2925,6 +2925,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);
}
if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) {
return getReimbursementQueuedActionMessage(reportAction, getReport(parentReportID), false);
}
return reportAction?.message?.[0]?.text ?? '';
}

/**
* Get the title for a report.
*/
Expand All @@ -2945,11 +2961,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

0 comments on commit 159628b

Please sign in to comment.