Skip to content

fix: expense - user avatar is shown in report in which expense is notadded #67549

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
];

let currentAccountID: number | undefined;
Onyx.connect({

Check warning on line 167 in src/libs/SearchUIUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 167 in src/libs/SearchUIUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (session) => {
currentAccountID = session?.accountID;
Expand Down Expand Up @@ -1172,7 +1172,7 @@
action: getAction(data, allViolations, key, currentSearch, actions),
groupedBy: CONST.SEARCH.GROUP_BY.REPORTS,
keyForList: reportItem.reportID,
from: data.personalDetailsList?.[reportItem.accountID ?? CONST.DEFAULT_NUMBER_ID],
from: transactions.length > 0 ? data.personalDetailsList[data?.[reportKey as ReportKey]?.accountID ?? CONST.DEFAULT_NUMBER_ID] : emptyPersonalDetails,
to: !shouldShowBlankTo && reportItem.managerID ? data.personalDetailsList?.[reportItem.managerID] : emptyPersonalDetails,
transactions,
...(reportPendingAction ? {pendingAction: reportPendingAction} : {}),
Expand Down Expand Up @@ -1220,8 +1220,10 @@
};
if (reportIDToTransactions[reportKey]?.transactions) {
reportIDToTransactions[reportKey].transactions.push(transaction);
reportIDToTransactions[reportKey].from = data.personalDetailsList[data?.[reportKey as ReportKey]?.accountID ?? CONST.DEFAULT_NUMBER_ID];
} else if (reportIDToTransactions[reportKey]) {
reportIDToTransactions[reportKey].transactions = [transaction];
reportIDToTransactions[reportKey].from = data.personalDetailsList[data?.[reportKey as ReportKey]?.accountID ?? CONST.DEFAULT_NUMBER_ID];
}
}
}
Expand Down
58 changes: 58 additions & 0 deletions tests/unit/Search/SearchUIUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const reportID = '123456789';
const reportID2 = '11111';
const reportID3 = '99999';
const reportID4 = '6155022250251839';
const reportID5 = '22222';
const transactionID = '1';
const transactionID2 = '2';
const transactionID3 = '3';
Expand Down Expand Up @@ -232,6 +233,27 @@ const searchResults: OnyxTypes.SearchResults = {
created: '2025-03-05 16:34:27',
type: 'chat',
},
[`report_${reportID5}`]: {
accountID: adminAccountID,
action: 'view',
chatReportID: '1706144653204915',
created: '2024-12-21 13:05:20',
currency: 'USD',
isOneTransactionReport: true,
isPolicyExpenseChat: false,
isWaitingOnBankAccount: false,
managerID: adminAccountID,
nonReimbursableTotal: 0,
ownerAccountID: adminAccountID,
policyID,
reportID: reportID5,
reportName: 'Expense Report #123',
stateNum: 0,
statusNum: 0,
total: 0,
type: 'expense',
unheldTotal: 0,
},
[`transactions_${transactionID}`]: {
accountID: adminAccountID,
action: 'view',
Expand Down Expand Up @@ -975,6 +997,42 @@ const transactionReportGroupListItems = [
},
transactions: [transactionsListItems.at(2), transactionsListItems.at(3)],
},
{
groupedBy: 'reports',
accountID: 18439984,
action: 'view',
chatReportID: '1706144653204915',
created: '2024-12-21 13:05:20',
currency: 'USD',
from: {
accountID: CONST.REPORT.OWNER_ACCOUNT_ID_FAKE,
avatar: '',
displayName: undefined,
login: undefined,
},
isOneTransactionReport: true,
isPolicyExpenseChat: false,
isWaitingOnBankAccount: false,
keyForList: reportID5,
managerID: 18439984,
nonReimbursableTotal: 0,
ownerAccountID: 18439984,
policyID: 'A1B2C3',
reportID: reportID5,
reportName: 'Expense Report #123',
stateNum: 0,
statusNum: 0,
to: {
accountID: 0,
avatar: '',
displayName: undefined,
login: undefined,
},
total: 0,
transactions: [],
type: 'expense',
unheldTotal: 0,
},
] as TransactionReportGroupListItemType[];

describe('SearchUIUtils', () => {
Expand Down
Loading