Skip to content

Commit

Permalink
Merge pull request #50347 from cretadn22/fix-regression
Browse files Browse the repository at this point in the history
Updated selected transaction If getting new updates (also fixed for cases where the status is set to ALL)

(cherry picked from commit 4e17806)

(CP triggered by thienlnam)
  • Loading branch information
thienlnam authored and OSBotify committed Oct 7, 2024
1 parent 8e8698e commit 6062d05
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,15 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
}, [searchResults?.search?.type, setShouldShowStatusBarLoading, shouldShowLoadingState, type]);

useEffect(() => {
if (type === CONST.SEARCH.DATA_TYPES.CHAT) {
return;
}
const newTransactionList: SelectedTransactions = {};
data.forEach((report) => {
const transactionsData: TransactionListItemType[] = Object.hasOwn(report, 'transactions') && 'transactions' in report ? report.transactions : [];
transactionsData.forEach((transaction) => {
if (status === CONST.SEARCH.STATUS.EXPENSE.ALL) {
data.forEach((transaction) => {
if (!Object.hasOwn(transaction, 'transactionID') || !('transactionID' in transaction)) {
return;
}
if (!Object.keys(selectedTransactions).includes(transaction.transactionID)) {
return;
}
Expand All @@ -203,7 +208,25 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
canDelete: transaction.canDelete,
};
});
});
} else {
data.forEach((report) => {
if (!Object.hasOwn(report, 'transactions') || !('transactions' in report)) {
return;
}
report.transactions.forEach((transaction) => {
if (!Object.keys(selectedTransactions).includes(transaction.transactionID)) {
return;
}
newTransactionList[transaction.transactionID] = {
action: transaction.action,
canHold: transaction.canHold,
canUnhold: transaction.canUnhold,
isSelected: selectedTransactions[transaction.transactionID].isSelected,
canDelete: transaction.canDelete,
};
});
});
}
setSelectedTransactions(newTransactionList, data);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [data, setSelectedTransactions]);
Expand Down

0 comments on commit 6062d05

Please sign in to comment.