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
2 changes: 1 addition & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ function MoneyReportHeader({
);
const transactionID = duplicateTransaction?.transactionID;
const iouAction = getIOUActionForReportID(moneyRequestReport?.reportID, transactionID);
const createdTransactionThreadReport = createTransactionThreadReport(moneyRequestReport, iouAction);
const createdTransactionThreadReport = createTransactionThreadReport(introSelected, moneyRequestReport, iouAction);
threadID = createdTransactionThreadReport?.reportID;
}
Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(threadID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
const [userBillingGraceEndPeriodCollection] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [lastDistanceExpenseType] = useOnyx(ONYXKEYS.NVP_LAST_DISTANCE_EXPENSE_TYPE);
const [reportLayoutGroupBy] = useOnyx(ONYXKEYS.NVP_REPORT_LAYOUT_GROUP_BY);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);

const shouldShowGroupedTransactions = isExpenseReport(report) && !isIOUReport(report);

Expand Down Expand Up @@ -310,7 +311,7 @@
return groupTransactionsByTag(sortedTransactions, report, localeCompare);
}
return groupTransactionsByCategory(sortedTransactions, report, localeCompare);
}, [sortedTransactions, currentGroupBy, report?.reportID, report?.currency, localeCompare, shouldShowGroupedTransactions]);

Check warning on line 314 in src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has a missing dependency: 'report'. Either include it or remove the dependency array

Check warning on line 314 in src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useMemo has a missing dependency: 'report'. Either include it or remove the dependency array

const visualOrderTransactionIDs = useMemo(() => {
if (!shouldShowGroupedTransactions || groupedTransactions.length === 0) {
Expand Down Expand Up @@ -399,7 +400,7 @@

if (!reportIDToNavigate) {
const transaction = sortedTransactions.find((t) => t.transactionID === activeTransactionID);
const transactionThreadReport = createTransactionThreadReport(report, iouAction, transaction);
const transactionThreadReport = createTransactionThreadReport(introSelected, report, iouAction, transaction);
if (transactionThreadReport) {
reportIDToNavigate = transactionThreadReport.reportID;
routeParams.reportID = reportIDToNavigate;
Expand All @@ -417,7 +418,7 @@
Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute(routeParams));
});
},
[reportActions, visualOrderTransactionIDs, sortedTransactions, report, markReportIDAsExpense],
[reportActions, visualOrderTransactionIDs, sortedTransactions, report, markReportIDAsExpense, introSelected],
);

const {amountColumnSize, dateColumnSize, taxAmountColumnSize} = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const parentReportActionIDsSelector = (reportActions: OnyxEntry<OnyxTypes.Report

function MoneyRequestReportTransactionsNavigation({currentTransactionID, isFromReviewDuplicates}: MoneyRequestReportRHPNavigationButtonsProps) {
const [transactionIDsList = getEmptyArray<string>()] = useOnyx(ONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);

const {markReportIDAsExpense} = useWideRHPActions();

Expand Down Expand Up @@ -133,7 +134,7 @@ function MoneyRequestReportTransactionsNavigation({currentTransactionID, isFromR
}
// The transaction thread doesn't exist yet, so we should create it
if (!nextThreadReportID) {
const transactionThreadReport = createTransactionThreadReport(parentReport, nextParentReportAction, nextTransaction);
const transactionThreadReport = createTransactionThreadReport(introSelected, parentReport, nextParentReportAction, nextTransaction);
navigationParams.reportID = transactionThreadReport?.reportID;
}
// Wait for the next frame to ensure Onyx has processed the optimistic data updates from setOptimisticTransactionThread or createTransactionThreadReport before navigating
Expand Down Expand Up @@ -161,7 +162,7 @@ function MoneyRequestReportTransactionsNavigation({currentTransactionID, isFromR
}
// The transaction thread doesn't exist yet, so we should create it
if (!prevThreadReportID) {
const transactionThreadReport = createTransactionThreadReport(parentReport, prevParentReportAction, prevTransaction);
const transactionThreadReport = createTransactionThreadReport(introSelected, parentReport, prevParentReportAction, prevTransaction);
navigationParams.reportID = transactionThreadReport?.reportID;
}
// Wait for the next frame to ensure Onyx has processed the optimistic data updates from setOptimisticTransactionThread or createTransactionThreadReport before navigating
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/MoneyRequestAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function MoneyRequestAction({
const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`];
const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${requestReportID}`];
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`, {canEvict: false});
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const StyleUtils = useStyleUtils();
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -125,7 +126,7 @@ function MoneyRequestAction({
const transactionID = isMoneyRequestAction(action) ? getOriginalMessage(action)?.IOUTransactionID : CONST.DEFAULT_NUMBER_ID;

if (!action?.childReportID && transactionID && action.reportActionID) {
const transactionThreadReport = createTransactionThreadReport(iouReport, action);
const transactionThreadReport = createTransactionThreadReport(introSelected, iouReport, action);
if (shouldOpenReportInRHP) {
Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID: transactionThreadReport?.reportID, backTo: Navigation.getActiveRoute()}));
return;
Expand Down
16 changes: 13 additions & 3 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ function Search({
const [offset, setOffset] = useState(0);

const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const previousTransactions = usePrevious(transactions);
const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS);
const [outstandingReportsByPolicyID] = useOnyx(ONYXKEYS.DERIVED.OUTSTANDING_REPORTS_BY_POLICY_ID);
Expand Down Expand Up @@ -918,7 +919,7 @@ function Search({
if (isTransactionItem && !item?.reportAction?.childReportID) {
// If the report is unreported (self DM), we want to open the track expense thread instead of a report with an ID of 0
const shouldOpenTransactionThread = !isOneTransactionReport(item.report) || item.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;
createAndOpenSearchTransactionThread(item, backTo, item?.reportAction?.childReportID, undefined, shouldOpenTransactionThread);
createAndOpenSearchTransactionThread(item, introSelected, backTo, item?.reportAction?.childReportID, undefined, shouldOpenTransactionThread);
if (shouldOpenTransactionThread) {
return;
}
Expand Down Expand Up @@ -959,7 +960,7 @@ function Search({
const firstTransaction = item.transactions.at(0);
if (item.isOneTransactionReport && firstTransaction && transactionPreviewData) {
if (!firstTransaction?.reportAction?.childReportID) {
createAndOpenSearchTransactionThread(firstTransaction, backTo, firstTransaction?.reportAction?.childReportID, transactionPreviewData, false);
createAndOpenSearchTransactionThread(firstTransaction, introSelected, backTo, firstTransaction?.reportAction?.childReportID, transactionPreviewData, false);
} else {
setOptimisticDataForTransactionThreadPreview(firstTransaction, transactionPreviewData, firstTransaction?.reportAction?.childReportID);
}
Expand Down Expand Up @@ -994,7 +995,16 @@ function Search({

requestAnimationFrame(() => Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID, backTo})));
},
[isMobileSelectionModeEnabled, markReportIDAsExpense, toggleTransaction, handleSearch, searchKey, markReportIDAsMultiTransactionExpense, unmarkReportIDAsMultiTransactionExpense],
[
isMobileSelectionModeEnabled,
markReportIDAsExpense,
toggleTransaction,
handleSearch,
searchKey,
markReportIDAsMultiTransactionExpense,
unmarkReportIDAsMultiTransactionExpense,
introSelected,
],
);

const currentColumns = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function TransactionGroupListExpanded<TItem extends ListItem>({
const currentUserDetails = useCurrentUserPersonalDetails();
const {translate} = useLocalize();
const [isMobileSelectionModeEnabled] = useOnyx(ONYXKEYS.MOBILE_SELECTION_MODE);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [visibleColumns] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, {selector: columnsSelector});

const transactionsSnapshotMetadata = transactionsSnapshot?.search;
Expand Down Expand Up @@ -94,7 +95,7 @@ function TransactionGroupListExpanded<TItem extends ListItem>({

const navigateToTransactionThread = () => {
if (!transactionItem?.reportAction?.childReportID) {
createAndOpenSearchTransactionThread(transactionItem, backTo, transactionItem?.reportAction?.childReportID);
createAndOpenSearchTransactionThread(transactionItem, introSelected, backTo, transactionItem?.reportAction?.childReportID);
return;
}
markReportIDAsExpense(reportID);
Expand Down
3 changes: 2 additions & 1 deletion src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,7 @@ function getTaskSections(
/** Creates transaction thread report and navigates to it from the search page */
function createAndOpenSearchTransactionThread(
item: TransactionListItemType,
introSelected: OnyxEntry<OnyxTypes.IntroSelected>,
backTo: string,
IOUTransactionID?: string,
transactionPreviewData?: TransactionPreviewData,
Expand Down Expand Up @@ -1955,7 +1956,7 @@ function createAndOpenSearchTransactionThread(
const transactionViolations = shouldPassTransactionData ? item.violations : undefined;
// Use the full reportAction to preserve originalMessage.type (e.g., "track") for proper expense type detection
const reportActionToPass = iouReportAction ?? item.reportAction ?? ({reportActionID} as OnyxTypes.ReportAction);
transactionThreadReport = createTransactionThreadReport(item.report, reportActionToPass, transaction, transactionViolations);
transactionThreadReport = createTransactionThreadReport(introSelected, item.report, reportActionToPass, transaction, transactionViolations);
}

if (shouldNavigate) {
Expand Down
11 changes: 6 additions & 5 deletions src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
/** @deprecated This value is deprecated and will be removed soon after migration. Use the email from useCurrentUserPersonalDetails hook instead. */
let deprecatedCurrentUserLogin: string | undefined;

Onyx.connect({

Check warning on line 317 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -328,7 +328,7 @@
},
});

Onyx.connect({

Check warning on line 331 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => (conciergeReportIDOnyxConnect = value),
});
Expand All @@ -336,7 +336,7 @@
// map of reportID to all reportActions for that report
const allReportActions: OnyxCollection<ReportActions> = {};

Onyx.connect({

Check warning on line 339 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
callback: (actions, key) => {
if (!key || !actions) {
Expand All @@ -348,7 +348,7 @@
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 351 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -357,7 +357,7 @@
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList> = {};
Onyx.connect({

Check warning on line 360 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand All @@ -372,7 +372,7 @@
});

let onboarding: OnyxEntry<Onboarding>;
Onyx.connect({

Check warning on line 375 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_ONBOARDING,
callback: (val) => {
if (Array.isArray(val)) {
Expand All @@ -383,7 +383,7 @@
});

let deprecatedIntroSelected: OnyxEntry<IntroSelected> = {};
Onyx.connect({

Check warning on line 386 in src/libs/actions/Report/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_INTRO_SELECTED,
callback: (val) => (deprecatedIntroSelected = val),
});
Expand Down Expand Up @@ -1320,8 +1320,8 @@

// Prepare guided setup data only when nvp_introSelected is set and onboarding is not completed
// OldDot users will never have nvp_introSelected set, so they will not see guided setup messages
if (deprecatedIntroSelected && !isOnboardingCompleted && !isInviteOnboardingComplete && !hasOpenReportWithGuidedSetupData) {
const {choice, inviteType} = deprecatedIntroSelected;
if (introSelected && !isOnboardingCompleted && !isInviteOnboardingComplete && !hasOpenReportWithGuidedSetupData) {
const {choice, inviteType} = introSelected;
const isInviteIOUorInvoice = inviteType === CONST.ONBOARDING_INVITE_TYPES.IOU || inviteType === CONST.ONBOARDING_INVITE_TYPES.INVOICE;
const isInviteChoiceCorrect = choice === CONST.ONBOARDING_CHOICES.ADMIN || choice === CONST.ONBOARDING_CHOICES.SUBMIT || choice === CONST.ONBOARDING_CHOICES.CHAT_SPLIT;

Expand All @@ -1333,10 +1333,10 @@
}

const onboardingData = prepareOnboardingOnyxData({
introSelected: deprecatedIntroSelected,
introSelected,
engagementChoice: choice,
onboardingMessage,
companySize: deprecatedIntroSelected?.companySize as OnboardingCompanySize,
companySize: introSelected?.companySize as OnboardingCompanySize,
});

if (onboardingData) {
Expand Down Expand Up @@ -1563,6 +1563,7 @@
}

function createTransactionThreadReport(
introSelected: OnyxEntry<IntroSelected>,
iouReport?: OnyxEntry<Report>,
iouReportAction?: OnyxEntry<ReportAction>,
transaction?: Transaction,
Expand Down Expand Up @@ -1603,7 +1604,7 @@
const shouldAddPendingFields = transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD || iouReportAction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD;
openReport(
optimisticTransactionThreadReportID,
deprecatedIntroSelected,
introSelected,
undefined,
// eslint-disable-next-line @typescript-eslint/no-deprecated
deprecatedCurrentUserLogin ? [deprecatedCurrentUserLogin] : [],
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Search/SearchMoneyRequestReportPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
}
Navigation.dismissModal();
}
}, [report]);

Check warning on line 92 in src/pages/Search/SearchMoneyRequestReportPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useEffect has missing dependencies: 'isFocused' and 'prevReport'. Either include them or remove the dependency array

useEffect(() => {
// Update last visit time when the expense super wide RHP report is focused
Expand Down Expand Up @@ -200,7 +200,7 @@

if (transactionThreadReportID === CONST.FAKE_REPORT_ID && oneTransactionID) {
const iouAction = getIOUActionForTransactionID(reportActions, oneTransactionID);
createTransactionThreadReport(report, iouAction);
createTransactionThreadReport(introSelected, report, iouAction);
Comment thread
JS00001 marked this conversation as resolved.
return;
}

Expand Down Expand Up @@ -262,10 +262,11 @@
hasCreatedLegacyThreadRef.current = true;

const violations = allReportViolations[transaction.transactionID] ?? snapshotViolations;
createTransactionThreadReport(report, undefined, transaction, violations);
createTransactionThreadReport(introSelected, report, undefined, transaction, violations);
}, [
allReportTransactions,
allReportViolations,
introSelected,
report,
reportActions,
reportIDFromRoute,
Expand Down
8 changes: 4 additions & 4 deletions src/pages/inbox/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr
const currentReportTransaction = getReportTransactions(reportID).filter((transaction) => transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
const oneTransactionID = currentReportTransaction.at(0)?.transactionID;
const iouAction = getIOUActionForReportID(reportID, oneTransactionID);
createTransactionThreadReport(report, iouAction, currentReportTransaction.at(0));
}, [report, reportID]);
createTransactionThreadReport(introSelected, report, iouAction, currentReportTransaction.at(0));
}, [introSelected, report, reportID]);

const isInviteOnboardingComplete = introSelected?.isInviteOnboardingComplete ?? false;
const isOnboardingCompleted = onboarding?.hasCompletedGuidedSetupFlow ?? false;
Expand Down Expand Up @@ -965,8 +965,8 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr

// For legacy transactions, pass undefined as IOU action and the transaction object
// It will be created optimistically and in the backend when call openReport
createTransactionThreadReport(report, undefined, transaction);
}, [report, visibleTransactions, transactionThreadReport, transactionThreadReportID, reportID, route.name]);
createTransactionThreadReport(introSelected, report, undefined, transaction);
}, [introSelected, report, visibleTransactions, transactionThreadReport, transactionThreadReportID, reportID, route.name]);

const lastRoute = usePrevious(route);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/inbox/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ function PureReportActionItem({

// If no childReportID exists, create transaction thread on-demand
if (!action.childReportID) {
const createdTransactionThreadReport = createTransactionThreadReport(iouReport, action);
const createdTransactionThreadReport = createTransactionThreadReport(introSelected, iouReport, action);
if (createdTransactionThreadReport?.reportID) {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(createdTransactionThreadReport.reportID, undefined, undefined, Navigation.getActiveRoute()));
return;
Expand Down
Loading
Loading