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
30 changes: 28 additions & 2 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8458,7 +8458,15 @@ const CONST = {
},
INVOICE: {},
TASK: {},
TRIP: {},
TRIP: {
START_DATE: this.TABLE_COLUMNS.START_DATE,
END_DATE: this.TABLE_COLUMNS.END_DATE,
STATUS: this.TABLE_COLUMNS.STATUS,
TRIP_NAME: this.TABLE_COLUMNS.TRIP_NAME,
TRAVELER: this.TABLE_COLUMNS.TRAVELER,
TOTAL: this.TABLE_COLUMNS.TOTAL,
ACTION: this.TABLE_COLUMNS.ACTION,
},
CHAT: {},
};
},
Expand Down Expand Up @@ -8562,7 +8570,15 @@ const CONST = {
],
INVOICE: [],
TASK: [],
TRIP: [],
TRIP: [
this.TABLE_COLUMNS.START_DATE,
this.TABLE_COLUMNS.END_DATE,
this.TABLE_COLUMNS.STATUS,
this.TABLE_COLUMNS.TRIP_NAME,
this.TABLE_COLUMNS.TRAVELER,
this.TABLE_COLUMNS.TOTAL,
this.TABLE_COLUMNS.ACTION,
],
CHAT: [],
};
},
Expand Down Expand Up @@ -8631,6 +8647,12 @@ const CONST = {
},
},
GROUP_COLUMN_PREFIX: 'group',
// Status the backend works out for each trip row, from the trip's dates and Spotnana status
TRIP_STATUS: {
UPCOMING: 'upcoming',
DONE: 'done',
CANCELED: 'canceled',
},
TABLE_COLUMNS: {
RECEIPT: 'receipt',
DATE: 'date',
Expand Down Expand Up @@ -8711,6 +8733,10 @@ const CONST = {
GROUP_WITHDRAWAL_STATUS: 'groupWithdrawalStatus',
GROUP_AMOUNT_DEBITED: 'groupAmountDebited',
GROUP_AMOUNT_REIMBURSED: 'groupAmountReimbursed',
START_DATE: 'startDate',
END_DATE: 'endDate',
TRIP_NAME: 'tripName',
TRAVELER: 'traveler',
},
SYNTAX_OPERATORS: {
AND: 'and',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import useReportIsArchived from '@hooks/useReportIsArchived';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSearchShouldCalculateTotals from '@hooks/useSearchShouldCalculateTotals';
import useShareActions from '@hooks/useShareActions';
import useShouldReturnTripRooms from '@hooks/useShouldReturnTripRooms';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';
Expand Down Expand Up @@ -170,6 +171,7 @@ function MoneyReportHeaderSecondaryActionsInner({reportID, primaryAction, isRepo
const {isDelegateAccessRestricted} = useDelegateNoAccessState();
const {showDelegateNoAccessModal} = useDelegateNoAccessActions();
const {currentSearchQueryJSON, currentSearchKey} = useSearchQueryContext();
const shouldReturnTripRooms = useShouldReturnTripRooms(currentSearchQueryJSON?.type);
const {currentSearchResults} = useSearchResultsContext();
const shouldCalculateTotals = useSearchShouldCalculateTotals(currentSearchKey, true);

Expand Down Expand Up @@ -266,6 +268,7 @@ function MoneyReportHeaderSecondaryActionsInner({reportID, primaryAction, isRepo
offset: 0,
queryJSON: currentSearchQueryJSON,
isLoading: !!currentSearchResults?.search?.isLoading,
shouldReturnTripRooms,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import usePermissions from '@hooks/usePermissions';
import usePolicy from '@hooks/usePolicy';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useSearchShouldCalculateTotals from '@hooks/useSearchShouldCalculateTotals';
import useShouldReturnTripRooms from '@hooks/useShouldReturnTripRooms';
import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';

import {generateDefaultWorkspaceName} from '@libs/actions/Policy/Policy';
Expand Down Expand Up @@ -120,6 +121,7 @@ function PayPrimaryAction({reportID, chatReportID, isDisabled}: PayPrimaryAction
const isAnyTransactionOnHold = hasHeldExpensesReportUtils(transactions);

const {currentSearchQueryJSON, currentSearchKey} = useSearchQueryContext();
const shouldReturnTripRooms = useShouldReturnTripRooms(currentSearchQueryJSON?.type);
const {currentSearchResults} = useSearchResultsContext();
const shouldCalculateTotals = useSearchShouldCalculateTotals(currentSearchKey, true);

Expand Down Expand Up @@ -200,6 +202,7 @@ function PayPrimaryAction({reportID, chatReportID, isDisabled}: PayPrimaryAction
offset: 0,
queryJSON: currentSearchQueryJSON,
isLoading: !!currentSearchResults?.search?.isLoading,
shouldReturnTripRooms,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import usePermissions from '@hooks/usePermissions';
import {useGetPersonalDetailsByLogin} from '@hooks/usePersonalDetailByLogin';
import {usePersonalDetail} from '@hooks/usePersonalDetails';
import useSearchShouldCalculateTotals from '@hooks/useSearchShouldCalculateTotals';
import useShouldReturnTripRooms from '@hooks/useShouldReturnTripRooms';
import useStrictPolicyRules from '@hooks/useStrictPolicyRules';
import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';

Expand Down Expand Up @@ -135,6 +136,7 @@ function SubmitPrimaryActionContent({reportID, isDisabled}: SubmitPrimaryActionP
const canSubmitViaPDF = !!moneyRequestReport && isSubmitViaPDFAction(moneyRequestReport, accountID, policy);

const {currentSearchQueryJSON, currentSearchKey} = useSearchQueryContext();
const shouldReturnTripRooms = useShouldReturnTripRooms(currentSearchQueryJSON?.type);
const {currentSearchResults} = useSearchResultsContext();
const shouldCalculateTotals = useSearchShouldCalculateTotals(currentSearchKey, true);

Expand Down Expand Up @@ -214,6 +216,7 @@ function SubmitPrimaryActionContent({reportID, isDisabled}: SubmitPrimaryActionP
offset: 0,
queryJSON: currentSearchQueryJSON,
isLoading: !!currentSearchResults?.search?.isLoading,
shouldReturnTripRooms,
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useFilterPendingDeleteReports from '@hooks/useFilterPendingDeleteReports'
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useSearchSections from '@hooks/useSearchSections';
import useShouldReturnTripRooms from '@hooks/useShouldReturnTripRooms';
import useThemeStyles from '@hooks/useThemeStyles';

import {startSpan} from '@libs/telemetry/activeSpans';
Expand Down Expand Up @@ -129,6 +130,7 @@ function MoneyRequestReportNavigationContent({reportID, shouldDisplayNarrowVersi
// Lightweight subscriptions only: the current search query and its loading flag. These never mount
// the heavy useSearchSections subscription set, so the fast context path stays cheap.
const [lastSearchQuery] = useOnyx(ONYXKEYS.REPORT_NAVIGATION_LAST_SEARCH_QUERY);
const shouldReturnTripRooms = useShouldReturnTripRooms(lastSearchQuery?.queryJSON?.type);
const [isSearchLoading = false] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${lastSearchQuery?.queryJSON?.hash}`, {selector: searchLoadingSelector});

// Fast path: use the pre-computed IDs from the search context when they are usable and no page is in
Expand Down Expand Up @@ -230,6 +232,7 @@ function MoneyRequestReportNavigationContent({reportID, shouldDisplayNarrowVersi
searchKey: lastSearchQuery.searchKey,
isLoading: isSearchLoading,
shouldUpdateLastSearchParams: true,
shouldReturnTripRooms,
});
});
}
Expand Down
7 changes: 5 additions & 2 deletions src/components/Search/FilterDropdowns/DisplayPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useShouldReturnTripRooms from '@hooks/useShouldReturnTripRooms';
import useThemeStyles from '@hooks/useThemeStyles';

import {close} from '@libs/actions/Modal';
Expand Down Expand Up @@ -49,6 +50,7 @@ function DisplayPopup({queryJSON, searchResults, closeOverlay, onSort}: DisplayP
const {isLargeScreenWidth, isSmallScreenWidth} = useResponsiveLayout(); // eslint-disable-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const expensifyIcons = useMemoizedLazyExpensifyIcons(['Columns']);
const {updateFilterQueryParams} = useUpdateFilterQuery(queryJSON);
const shouldReturnTripRooms = useShouldReturnTripRooms(queryJSON.type);
Comment thread
suneox marked this conversation as resolved.
Resolved
const [searchAdvancedFilters = getEmptyObject<SearchAdvancedFiltersForm>()] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM);
const [selectedDisplayFilter, setSelectedDisplayFilter] = useState<
| typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT
Expand All @@ -64,7 +66,8 @@ function DisplayPopup({queryJSON, searchResults, closeOverlay, onSort}: DisplayP
const groupBy = groupBySections.flatMap((section) => section.options).find((option) => option.value === queryJSON.groupBy) ?? null;
const viewOptions = getViewOptions(translate);
const view = viewOptions.find((option) => option.value === queryJSON.view) ?? viewOptions.at(0);
const shouldShowColumnsButton = isLargeScreenWidth && (queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE || queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT);
const shouldShowColumnsButton =
isLargeScreenWidth && (queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE || queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT || shouldReturnTripRooms);

const limitValue = searchAdvancedFilters[CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT];

Expand All @@ -88,7 +91,7 @@ function DisplayPopup({queryJSON, searchResults, closeOverlay, onSort}: DisplayP
name={translate('search.display.sortBy')}
onPress={() => setSelectedDisplayFilter(CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY)}
sentryLabel={CONST.SENTRY_LABEL.SEARCH.FILTER_SORT_BY}
value={`${translate(getSearchColumnTranslationKey(sortByValue, queryJSON.type))} ${CONST.DOT_SEPARATOR} ${translate(`search.filters.sortOrder.${sortOrderValue}`)}`}
value={`${translate(getSearchColumnTranslationKey(sortByValue, queryJSON.type, shouldReturnTripRooms))} ${CONST.DOT_SEPARATOR} ${translate(`search.filters.sortOrder.${sortOrderValue}`)}`}
/>
{(isExpenseType || isTripType) && (
<MenuItemField
Expand Down
3 changes: 3 additions & 0 deletions src/components/Search/FilterDropdowns/SortByPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
import useIsVendorColumnAvailable from '@hooks/useIsVendorColumnAvailable';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useShouldReturnTripRooms from '@hooks/useShouldReturnTripRooms';
import useThemeStyles from '@hooks/useThemeStyles';

import {close} from '@libs/actions/Modal';
Expand Down Expand Up @@ -55,6 +56,7 @@ function SortByPopup({searchResults, queryJSON, groupBy, onSort, onSortOrderPres
const isVendorColumnAvailable = useIsVendorColumnAvailable();

const searchDataType = shouldUseLiveData ? CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT : searchResults?.search?.type;
const shouldReturnTripRooms = useShouldReturnTripRooms(searchDataType);
const currentColumns = !searchResults?.data
? []
: getColumnsToShow({
Expand All @@ -66,6 +68,7 @@ function SortByPopup({searchResults, queryJSON, groupBy, onSort, onSortOrderPres
sortBy: queryJSON.sortBy,
shouldShowViolationsColumn: queryHasViolationFilter(queryJSON),
isVendorColumnAvailable,
shouldReturnTripRooms,
});
const sortableColumns = getSortByOptions(currentColumns, translate, searchDataType);
const sortOrder = queryJSON.sortOrder;
Expand Down
70 changes: 70 additions & 0 deletions src/components/Search/SearchList/ListItem/TripListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import useIsSearchRowFocused from '@components/Search/hooks/useIsSearchRowFocused';
import ListItemComposed from '@components/SelectionList/ListItemComposed';

import useLayoutSpacing from '@hooks/useLayoutSpacing';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';

import variables from '@styles/variables';

import React from 'react';
import {View} from 'react-native';

import type {TripListItemProps} from './types';

import TripListItemRow from './TripListItemRow';

/**
* A trip row in search results. Tapping the row or its View action opens the trip room.
*/
function TripListItem({item, columns = [], showTooltip, isDisabled, onSelectRow, onFocus, shouldSyncFocus, isLastItem}: TripListItemProps) {
const styles = useThemeStyles();
const isFocused = useIsSearchRowFocused(item.keyForList);
const StyleUtils = useStyleUtils();
const {pageGutterMargin} = useLayoutSpacing();
const {isLargeScreenWidth} = useResponsiveLayout();

const listItemPressableStyle = [
styles.selectionListPressableItemWrapper,
styles.pv3,
styles.ph3,
// Background is applied on the parent wrapper, so keep this transparent
styles.bgTransparent,
styles.mh0,
isLargeScreenWidth && StyleUtils.getSearchTableRowPressableStyle(!!isLastItem, false, {vertical: variables.tableRowPaddingVertical}),
];

return (
<ListItemComposed
item={item}
shouldAllowTextSelection
pressableStyle={listItemPressableStyle}
containerStyle={!isLargeScreenWidth && styles.mb2}
isFocused={isFocused}
isDisabled={isDisabled}
shouldShowTooltip={showTooltip}
canSelectMultiple={false}
onSelectRow={onSelectRow}
onFocus={onFocus}
shouldSyncFocus={shouldSyncFocus}
pressableWrapperStyle={[
pageGutterMargin,
StyleUtils.getSearchRowBackgroundStyle(false),
!isLargeScreenWidth && styles.br2,
isLargeScreenWidth && isLastItem && [styles.tableBottomRadius, styles.overflowHidden],
]}
>
<View style={[styles.flex1, styles.userSelectNone]}>
<TripListItemRow
item={item}
columns={columns}
showTooltip={!!showTooltip}
onViewPress={() => onSelectRow(item)}
/>
</View>
</ListItemComposed>
);
}

export default TripListItem;
Loading
Loading