Skip to content

Commit

Permalink
fix hold case
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Nov 22, 2024
1 parent caf22b0 commit 9933888
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/Search/SearchPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ function SearchPageHeader({queryJSON, hash}: SearchPageHeaderProps) {
}

const options: Array<DropdownOption<SearchHeaderOptionValue>> = [];
const isAnyTransactionOnHold = Object.values(selectedTransactions).some((transaction) => transaction.isHeld);

const shouldShowApproveOption =
!isOffline &&
!isAnyTransactionOnHold &&
(selectedReports.length
? selectedReports.every((report) => report.action === CONST.SEARCH.ACTION_TYPES.APPROVE)
: selectedTransactionsKeys.every((id) => selectedTransactions[id].action === CONST.SEARCH.ACTION_TYPES.APPROVE));
Expand Down Expand Up @@ -200,6 +203,7 @@ function SearchPageHeader({queryJSON, hash}: SearchPageHeaderProps) {

const shouldShowPayOption =
!isOffline &&
// !isAnyTransactionOnHold &&
(selectedReports.length
? selectedReports.every((report) => report.action === CONST.SEARCH.ACTION_TYPES.PAY && report.policyID && lastPaymentMethods[report.policyID])
: selectedTransactionsKeys.every(
Expand Down
5 changes: 5 additions & 0 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import isSearchTopmostCentralPane from '@libs/Navigation/isSearchTopmostCentralP
import * as ReportUtils from '@libs/ReportUtils';
import * as SearchQueryUtils from '@libs/SearchQueryUtils';
import * as SearchUIUtils from '@libs/SearchUIUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import Navigation from '@navigation/Navigation';
import type {AuthScreensParamList} from '@navigation/types';
import EmptySearchView from '@pages/Search/EmptySearchView';
Expand Down Expand Up @@ -55,6 +56,7 @@ function mapTransactionItemToSelectedEntry(item: TransactionListItemType): [stri
isSelected: true,
canDelete: item.canDelete,
canHold: item.canHold,
isHeld: TransactionUtils.isOnHold(item),
canUnhold: item.canUnhold,
action: item.action,
reportID: item.reportID,
Expand Down Expand Up @@ -101,6 +103,7 @@ function prepareTransactionsList(item: TransactionListItemType, selectedTransact
isSelected: true,
canDelete: item.canDelete,
canHold: item.canHold,
isHeld: TransactionUtils.isOnHold(item),
canUnhold: item.canUnhold,
action: item.action,
reportID: item.reportID,
Expand Down Expand Up @@ -249,6 +252,7 @@ function Search({queryJSON, onSearchListScroll, isSearchScreenFocused, contentCo
newTransactionList[transaction.transactionID] = {
action: transaction.action,
canHold: transaction.canHold,
isHeld: TransactionUtils.isOnHold(transaction),
canUnhold: transaction.canUnhold,
isSelected: selectedTransactions[transaction.transactionID].isSelected,
canDelete: transaction.canDelete,
Expand All @@ -269,6 +273,7 @@ function Search({queryJSON, onSearchListScroll, isSearchScreenFocused, contentCo
newTransactionList[transaction.transactionID] = {
action: transaction.action,
canHold: transaction.canHold,
isHeld: TransactionUtils.isOnHold(transaction),
canUnhold: transaction.canUnhold,
isSelected: selectedTransactions[transaction.transactionID].isSelected,
canDelete: transaction.canDelete,
Expand Down
3 changes: 3 additions & 0 deletions src/components/Search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ type SelectedTransactionInfo = {
/** If the transaction can be put on hold */
canHold: boolean;

/** Whether the transaction is currently held */
isHeld: boolean;

/** If the transaction can be removed from hold */
canUnhold: boolean;

Expand Down

0 comments on commit 9933888

Please sign in to comment.