Skip to content

Commit 02a0edd

Browse files
authored
Merge pull request Expensify#67549 from mkzie2/mkzie2-issue/66714
fix: expense - user avatar is shown in report in which expense is notadded
2 parents 129ceb6 + f65a68c commit 02a0edd

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

src/libs/SearchUIUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ function getReportSections(
11751175
action: getAction(data, allViolations, key, currentSearch, actions),
11761176
groupedBy: CONST.SEARCH.GROUP_BY.REPORTS,
11771177
keyForList: reportItem.reportID,
1178-
from: data.personalDetailsList?.[reportItem.accountID ?? CONST.DEFAULT_NUMBER_ID],
1178+
from: transactions.length > 0 ? data.personalDetailsList[data?.[reportKey as ReportKey]?.accountID ?? CONST.DEFAULT_NUMBER_ID] : emptyPersonalDetails,
11791179
to: !shouldShowBlankTo && reportItem.managerID ? data.personalDetailsList?.[reportItem.managerID] : emptyPersonalDetails,
11801180
transactions,
11811181
...(reportPendingAction ? {pendingAction: reportPendingAction} : {}),
@@ -1223,8 +1223,10 @@ function getReportSections(
12231223
};
12241224
if (reportIDToTransactions[reportKey]?.transactions) {
12251225
reportIDToTransactions[reportKey].transactions.push(transaction);
1226+
reportIDToTransactions[reportKey].from = data.personalDetailsList[data?.[reportKey as ReportKey]?.accountID ?? CONST.DEFAULT_NUMBER_ID];
12261227
} else if (reportIDToTransactions[reportKey]) {
12271228
reportIDToTransactions[reportKey].transactions = [transaction];
1229+
reportIDToTransactions[reportKey].from = data.personalDetailsList[data?.[reportKey as ReportKey]?.accountID ?? CONST.DEFAULT_NUMBER_ID];
12281230
}
12291231
}
12301232
}

tests/unit/Search/SearchUIUtilsTest.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const reportID = '123456789';
2828
const reportID2 = '11111';
2929
const reportID3 = '99999';
3030
const reportID4 = '6155022250251839';
31+
const reportID5 = '22222';
3132
const transactionID = '1';
3233
const transactionID2 = '2';
3334
const transactionID3 = '3';
@@ -232,6 +233,27 @@ const searchResults: OnyxTypes.SearchResults = {
232233
created: '2025-03-05 16:34:27',
233234
type: 'chat',
234235
},
236+
[`report_${reportID5}`]: {
237+
accountID: adminAccountID,
238+
action: 'view',
239+
chatReportID: '1706144653204915',
240+
created: '2024-12-21 13:05:20',
241+
currency: 'USD',
242+
isOneTransactionReport: true,
243+
isPolicyExpenseChat: false,
244+
isWaitingOnBankAccount: false,
245+
managerID: adminAccountID,
246+
nonReimbursableTotal: 0,
247+
ownerAccountID: adminAccountID,
248+
policyID,
249+
reportID: reportID5,
250+
reportName: 'Expense Report #123',
251+
stateNum: 0,
252+
statusNum: 0,
253+
total: 0,
254+
type: 'expense',
255+
unheldTotal: 0,
256+
},
235257
[`transactions_${transactionID}`]: {
236258
accountID: adminAccountID,
237259
action: 'view',
@@ -1005,6 +1027,42 @@ const transactionReportGroupListItems = [
10051027
},
10061028
transactions: [transactionsListItems.at(2), transactionsListItems.at(3)],
10071029
},
1030+
{
1031+
groupedBy: 'reports',
1032+
accountID: 18439984,
1033+
action: 'view',
1034+
chatReportID: '1706144653204915',
1035+
created: '2024-12-21 13:05:20',
1036+
currency: 'USD',
1037+
from: {
1038+
accountID: CONST.REPORT.OWNER_ACCOUNT_ID_FAKE,
1039+
avatar: '',
1040+
displayName: undefined,
1041+
login: undefined,
1042+
},
1043+
isOneTransactionReport: true,
1044+
isPolicyExpenseChat: false,
1045+
isWaitingOnBankAccount: false,
1046+
keyForList: reportID5,
1047+
managerID: 18439984,
1048+
nonReimbursableTotal: 0,
1049+
ownerAccountID: 18439984,
1050+
policyID: 'A1B2C3',
1051+
reportID: reportID5,
1052+
reportName: 'Expense Report #123',
1053+
stateNum: 0,
1054+
statusNum: 0,
1055+
to: {
1056+
accountID: 0,
1057+
avatar: '',
1058+
displayName: undefined,
1059+
login: undefined,
1060+
},
1061+
total: 0,
1062+
transactions: [],
1063+
type: 'expense',
1064+
unheldTotal: 0,
1065+
},
10081066
] as TransactionReportGroupListItemType[];
10091067

10101068
describe('SearchUIUtils', () => {

0 commit comments

Comments
 (0)