Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function ReportListItemHeader<TItem extends ListItem>({
const StyleUtils = useStyleUtils();
const theme = useTheme();
const {currentSearchHash} = useSearchContext();
const {isLargeScreenWidth} = useResponsiveLayout();
const {isLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const thereIsFromAndTo = !!reportItem?.from && !!reportItem?.to;
const showUserInfo = (reportItem.type === CONST.REPORT.TYPE.IOU && thereIsFromAndTo) || (reportItem.type === CONST.REPORT.TYPE.EXPENSE && !!reportItem?.from);

Expand All @@ -175,7 +175,7 @@ function ReportListItemHeader<TItem extends ListItem>({
theme.highlightBG;

const handleOnButtonPress = () => {
handleActionButtonPress(currentSearchHash, reportItem, () => onSelectRow(reportItem as unknown as TItem));
handleActionButtonPress(currentSearchHash, reportItem, () => onSelectRow(reportItem as unknown as TItem), shouldUseNarrowLayout && !!canSelectMultiple);
};
return !isLargeScreenWidth ? (
<View>
Expand Down
6 changes: 3 additions & 3 deletions src/components/SelectionList/Search/TransactionListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function TransactionListItem<TItem extends ListItem>({
const styles = useThemeStyles();
const theme = useTheme();

const {isLargeScreenWidth} = useResponsiveLayout();
const {isLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const {currentSearchHash} = useSearchContext();

const listItemPressableStyle = [
Expand Down Expand Up @@ -104,7 +104,7 @@ function TransactionListItem<TItem extends ListItem>({
<UserInfoAndActionButtonRow
item={transactionItem}
handleActionButtonPress={() => {
handleActionButtonPress(currentSearchHash, transactionItem, () => onSelectRow(item));
handleActionButtonPress(currentSearchHash, transactionItem, () => onSelectRow(item), shouldUseNarrowLayout && !!canSelectMultiple);
}}
shouldShowUserInfo={!!transactionItem?.from}
/>
Expand All @@ -113,7 +113,7 @@ function TransactionListItem<TItem extends ListItem>({
transactionItem={transactionItem}
shouldShowTooltip={showTooltip}
onButtonPress={() => {
handleActionButtonPress(currentSearchHash, transactionItem, () => onSelectRow(item));
handleActionButtonPress(currentSearchHash, transactionItem, () => onSelectRow(item), shouldUseNarrowLayout && !!canSelectMultiple);
}}
onCheckboxPress={() => onCheckboxPress?.(item)}
shouldUseNarrowLayout={!isLargeScreenWidth}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ Onyx.connect({
waitForCollectionCallback: true,
});

function handleActionButtonPress(hash: number, item: TransactionListItemType | ReportListItemType, goToItem: () => void) {
function handleActionButtonPress(hash: number, item: TransactionListItemType | ReportListItemType, goToItem: () => void, isInMobileSelectionMode: boolean) {
// The transactionIDList is needed to handle actions taken on `status:all` where transactions on single expense reports can be approved/paid.
// We need the transactionID to display the loading indicator for that list item's action.
const transactionID = isTransactionListItemType(item) ? [item.transactionID] : undefined;
const allReportTransactions = (isReportListItemType(item) ? item.transactions : [item]) as SearchTransaction[];
const hasHeldExpense = hasHeldExpenses('', allReportTransactions);

if (hasHeldExpense) {
if (hasHeldExpense || isInMobileSelectionMode) {
goToItem();
return;
}
Expand Down
10 changes: 8 additions & 2 deletions tests/unit/Search/handleActionButtonPressTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,19 @@ describe('handleActionButtonPress', () => {
const searchHash = 1;
test('Should navigate to item when report has one transaction on hold', () => {
const goToItem = jest.fn(() => {});
handleActionButtonPress(searchHash, mockReportItemWithHold, goToItem);
handleActionButtonPress(searchHash, mockReportItemWithHold, goToItem, false);
expect(goToItem).toHaveBeenCalledTimes(1);
});

test('Should not navigate to item when the hold is removed', () => {
const goToItem = jest.fn(() => {});
handleActionButtonPress(searchHash, updatedMockReportItem, goToItem);
handleActionButtonPress(searchHash, updatedMockReportItem, goToItem, false);
expect(goToItem).toHaveBeenCalledTimes(0);
});

test('Should run goToItem callback when user is in mobile selection mode', () => {
const goToItem = jest.fn(() => {});
handleActionButtonPress(searchHash, updatedMockReportItem, goToItem, true);
expect(goToItem).toHaveBeenCalledTimes(1);
});
});