Skip to content
Closed
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
21 changes: 20 additions & 1 deletion src/components/SelectionList/Search/ReportListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {updateSearchResultsWithTransactionThreadReportID} from '@libs/actions/Search';
import Navigation from '@libs/Navigation/Navigation';
import {generateReportID} from '@libs/ReportUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand All @@ -28,6 +30,7 @@ function ReportListItem<TItem extends ListItem>({
onFocus,
onLongPressRow,
shouldSyncFocus,
queryJSONHash,
}: ReportListItemProps<TItem>) {
const reportItem = item as unknown as ReportListItemType;
const theme = useTheme();
Expand Down Expand Up @@ -62,11 +65,27 @@ function ReportListItem<TItem extends ListItem>({

const isFromSelfDM = transactionItem.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;

const reportID =
let reportID =
(!transactionItem.isFromOneTransactionReport || isFromSelfDM) && transactionItem.transactionThreadReportID !== CONST.REPORT.UNREPORTED_REPORT_ID
? transactionItem.transactionThreadReportID
: transactionItem.reportID;

// If we're trying to open a legacy transaction without a transaction thread, let's create the thread and navigate the user

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New expenses are created without transaction thread proactively so this is not only legacy transactions

Suggested change
// If we're trying to open a legacy transaction without a transaction thread, let's create the thread and navigate the user
// If we're trying to open a transaction without a transaction thread, let's create the thread and navigate the user

if (reportID === CONST.REPORT.UNREPORTED_REPORT_ID) {
reportID = generateReportID();
if (queryJSONHash) {
updateSearchResultsWithTransactionThreadReportID(queryJSONHash, transactionItem.transactionID, reportID);
}
Navigation.navigate(
ROUTES.SEARCH_REPORT.getRoute({
reportID,
backTo,
moneyRequestReportActionID: transactionItem.moneyRequestReportActionID,
transactionID: transactionItem.transactionID,
}),
);
return;
}
Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID, backTo}));
};

Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ type TaskListItemProps<TItem extends ListItem> = ListItemProps<TItem> & {
};

type ReportListItemProps<TItem extends ListItem> = ListItemProps<TItem> & {
queryJSONHash?: number;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc


/** Callback to fire when the item is pressed */
onSelectRow: (item: TItem, isOpenedAsReport?: boolean) => void;
};
Expand Down