Skip to content

Commit 3f7966f

Browse files
authored
Merge pull request Expensify#67927 from getusha/fix-crash-submitting-expense-ws
[CP Staging] fix: crash when submitting expense to workspace
2 parents 74b0c6c + aff8da3 commit 3f7966f

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/components/KYCWall/BaseKYCWall.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function KYCWall({
5555
const [bankAccountList = getEmptyObject<BankAccountList>()] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: true});
5656
const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {canBeMissing: true});
5757
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`, {canBeMissing: true});
58+
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true});
5859

5960
const {formatPhoneNumber} = useLocalize();
6061

@@ -121,7 +122,7 @@ function KYCWall({
121122
} else if (paymentMethod === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT || policy) {
122123
if (iouReport && isIOUReport(iouReport)) {
123124
if (policy) {
124-
const policyExpenseChatReportID = getPolicyExpenseChat(iouReport.ownerAccountID, policy.id)?.reportID;
125+
const policyExpenseChatReportID = getPolicyExpenseChat(iouReport.ownerAccountID, policy.id, allReports)?.reportID;
125126
if (!policyExpenseChatReportID) {
126127
const {policyExpenseChatReportID: newPolicyExpenseChatReportID} = moveIOUReportToPolicyAndInviteSubmitter(iouReport.reportID, policy.id, formatPhoneNumber) ?? {};
127128
savePreferredPaymentMethod(iouReport.policyID, policy.id, CONST.LAST_PAYMENT_METHOD.IOU, lastPaymentMethod?.[policy.id]);
@@ -157,7 +158,7 @@ function KYCWall({
157158
Navigation.navigate(bankAccountRoute);
158159
}
159160
},
160-
[addBankAccountRoute, addDebitCardRoute, chatReport, iouReport, onSelectPaymentMethod, formatPhoneNumber, lastPaymentMethod],
161+
[addBankAccountRoute, addDebitCardRoute, chatReport, iouReport, onSelectPaymentMethod, formatPhoneNumber, lastPaymentMethod, allReports],
161162
);
162163

163164
/**

src/libs/ReportUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5172,7 +5172,7 @@ function getReportNameInternal({
51725172
if (isMoneyRequestAction(parentReportAction)) {
51735173
const originalMessage = getOriginalMessage(parentReportAction);
51745174
const reportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
5175-
const last4Digits = reportPolicy?.achAccount?.accountNumber.slice(-4) ?? '';
5175+
const last4Digits = reportPolicy?.achAccount?.accountNumber?.slice(-4) ?? '';
51765176

51775177
if (originalMessage?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
51785178
if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
@@ -9237,7 +9237,7 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>,
92379237
let translationKey: TranslationPaths;
92389238
if (originalMessage?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
92399239
const reportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
9240-
const last4Digits = reportPolicy?.achAccount?.accountNumber.slice(-4) ?? '';
9240+
const last4Digits = reportPolicy?.achAccount?.accountNumber?.slice(-4) ?? '';
92419241

92429242
switch (originalMessage.paymentType) {
92439243
case CONST.IOU.PAYMENT_TYPE.ELSEWHERE:

0 commit comments

Comments
 (0)