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 @@ -159,6 +159,7 @@ function ExpenseReportListItem<TItem extends ListItem>({
{(hovered) => (
<View style={[styles.flex1]}>
<ExpenseReportListItemRow
hash={currentSearchHash}
item={reportItem}
columns={columns}
policy={snapshotPolicy}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import UserInfoCell from './UserInfoCell';
import WorkspaceCell from './WorkspaceCell';

type ExpenseReportListItemRowProps = {
hash: number;
item: ExpenseReportListItemType;
policy?: Policy;
showTooltip: boolean;
Expand All @@ -45,6 +46,7 @@ type ExpenseReportListItemRowProps = {
};

function ExpenseReportListItemRow({
hash,
item,
policy,
onCheckboxPress = () => {},
Expand Down Expand Up @@ -180,7 +182,10 @@ function ExpenseReportListItemRow({
),
[CONST.SEARCH.TABLE_COLUMNS.EXPORTED_TO]: (
<View style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.EXPORTED_TO)]}>
<ExportedIconCell reportID={item.reportID} />
<ExportedIconCell
reportID={item.reportID}
hash={hash}
/>
</View>
),
[CONST.SEARCH.TABLE_COLUMNS.ACTION]: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,33 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {getOriginalMessage, isExportedToIntegrationAction} from '@libs/ReportActionsUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {ReportAction} from '@src/types/onyx';

type ExportedIconCellProps = {
reportID?: string;
hash?: number;
};

function ExportedIconCell({reportID}: ExportedIconCellProps) {
function ExportedIconCell({reportID, hash}: ExportedIconCellProps) {
const theme = useTheme();
const styles = useThemeStyles();
const reportActions = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {canBeMissing: true});
const icons = useMemoizedLazyExpensifyIcons(['NetSuiteSquare', 'XeroSquare', 'IntacctSquare', 'QBOSquare', 'Table', 'ZenefitsSquare', 'BillComSquare', 'CertiniaSquare']);

// We need to subscribe directly to the snapshot to get the report actions because this can be rendered in either a group
// list (which has a separate hash than the current top-level search query) or in the top-level search query.
// This selector is specific to this edge-case (and thus is not in the selectors folder) and should be used in other places where the snapshot needs to be accessed
// eslint-disable-next-line rulesdir/no-inline-useOnyx-selector
Comment thread
JS00001 marked this conversation as resolved.
Resolved
const reportActions = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, {
canBeMissing: true,
selector: (snapshot) => {
return Object.entries(snapshot?.data ?? {})
.filter(([key]) => key === `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`)
.map(([, value]) => Object.values(value ?? {}) as ReportAction[])
.flat();
},
});

const actions = Object.values(reportActions[0] ?? {});
const icons = useMemoizedLazyExpensifyIcons(['NetSuiteSquare', 'XeroSquare', 'IntacctSquare', 'QBOSquare', 'Table', 'ZenefitsSquare', 'BillComSquare', 'CertiniaSquare']);

let isExportedToCsv = false;
let isExportedToNetsuite = false;
Expand All @@ -40,13 +55,13 @@ function ExportedIconCell({reportID}: ExportedIconCellProps) {
if (isExportedToIntegrationAction(action)) {
const label = getOriginalMessage(action)?.label;
isExportedToXero = isExportedToXero || label === CONST.EXPORT_LABELS.XERO;
isExportedToIntacct = isExportedToIntacct || label === CONST.EXPORT_LABELS.INTACCT;
isExportedToNetsuite = isExportedToNetsuite || label === CONST.EXPORT_LABELS.NETSUITE;
isExportedToQuickbooksOnline = isExportedToQuickbooksOnline || label === CONST.EXPORT_LABELS.QBO;
isExportedToQuickbooksDesktop = isExportedToQuickbooksDesktop || label === CONST.EXPORT_LABELS.QBD;
isExportedToZenefits = isExportedToZenefits || label === CONST.EXPORT_LABELS.ZENEFITS;
isExportedToBillCom = isExportedToBillCom || label === CONST.EXPORT_LABELS.BILLCOM;
isExportedToCertinia = isExportedToCertinia || label === CONST.EXPORT_LABELS.CERTINIA;
isExportedToIntacct = isExportedToIntacct || label === CONST.EXPORT_LABELS.INTACCT || label === CONST.EXPORT_LABELS.SAGE_INTACCT;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ function TransactionGroupListExpanded<TItem extends ListItem>({
const shouldShowBottomBorder = !isLastTransaction(index) && !isLargeScreenWidth;
const transactionRow = (
<TransactionItemRow
hash={transactionsQueryJSON?.hash}
report={transaction.report}
transactionItem={transaction}
violations={getTransactionViolations(transaction, violations, currentUserDetails.email ?? '', currentUserDetails.accountID, transaction.report, transaction.policy)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ function TransactionListItem<TItem extends ListItem>({
/>
)}
<TransactionItemRow
hash={currentSearchHash}
transactionItem={transactionItem}
report={transactionItem.report}
shouldShowTooltip={showTooltip}
Expand Down
7 changes: 6 additions & 1 deletion src/components/TransactionItemRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & {
};

type TransactionItemRowProps = {
hash?: number;
transactionItem: TransactionWithOptionalSearchFields;
report?: Report;
shouldUseNarrowLayout: boolean;
Expand Down Expand Up @@ -145,6 +146,7 @@ function getMerchantName(transactionItem: TransactionWithOptionalSearchFields, t
}

function TransactionItemRow({
hash,
transactionItem,
report,
shouldUseNarrowLayout,
Expand Down Expand Up @@ -538,7 +540,10 @@ function TransactionItemRow({
),
[CONST.SEARCH.TABLE_COLUMNS.EXPORTED_TO]: (
<View style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.EXPORTED_TO)]}>
<ExportedIconCell reportID={transactionItem.reportID} />
<ExportedIconCell
hash={hash}
reportID={transactionItem.reportID}
/>
</View>
),
}),
Expand Down
10 changes: 7 additions & 3 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3167,18 +3167,22 @@ function getColumnsToShow(
};

// If the user has set custom columns for the search, we need to respect their preference and order
if (!arraysEqual(Object.values(CONST.SEARCH.TYPE_DEFAULT_COLUMNS.EXPENSE), visibleColumns) && visibleColumns.length > 0) {
const filteredVisibleColumns = visibleColumns.filter((column) => {
return Object.values(CONST.SEARCH.TYPE_CUSTOM_COLUMNS.EXPENSE).includes(column as ValueOf<typeof CONST.SEARCH.TYPE_CUSTOM_COLUMNS.EXPENSE>);
});

if (!arraysEqual(Object.values(CONST.SEARCH.TYPE_DEFAULT_COLUMNS.EXPENSE), filteredVisibleColumns) && filteredVisibleColumns.length > 0) {
const requiredColumns = new Set<SearchColumnType>([CONST.SEARCH.TABLE_COLUMNS.AVATAR, CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, CONST.SEARCH.TABLE_COLUMNS.TYPE]);
const result: SearchColumnType[] = [];

// Add required columns that aren't in visibleColumns at the start
for (const col of requiredColumns) {
if (!visibleColumns.includes(col as SearchCustomColumnIds)) {
if (!filteredVisibleColumns.includes(col as SearchCustomColumnIds)) {
result.push(col);
}
}

for (const col of visibleColumns) {
for (const col of filteredVisibleColumns) {
result.push(col);
}

Expand Down