Preserve Search context when opening trip previews - #96283
Conversation
|
@sobitneupane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@sobitneupane, Gentle bump. thanks. |
|
Sorry for the delay @marufsharifi I will try to get this done by EOD tomorrow |
|
@marufsharifi The changes looks good. How can I create a test trip for testing purposes? |
|
@sobitneupane, Since I don't have access to a real trip, I used hardcoded mock data to reproduce this. Apply the patch below — it seeds a mock trip preview into the Concierge chat. Then open Concierge from Reports > Chats and tap the reservation / View button. trip-preview-repro.patchdiff --git a/src/Expensify.tsx b/src/Expensify.tsx
index 463f0d9adc7..30076bbfde7 100644
--- a/src/Expensify.tsx
+++ b/src/Expensify.tsx
@@ -263,6 +263,119 @@ function Expensify() {
initReconnect();
}, []);
+ // ------------------------------------------------------------------
+ // Mock trip data for testing PR #96283 — REMOVE AFTER TESTING.
+ // Seeds a mock trip room + a TRIPPREVIEW action in the Concierge chat
+ // so the real TripRoomPreview renders through the normal pipeline.
+ // ------------------------------------------------------------------
+ /* eslint-disable @typescript-eslint/no-unsafe-type-assertion, @typescript-eslint/naming-convention -- temporary local fixture for PR #96283 testing */
+ const [session] = useOnyx(ONYXKEYS.SESSION);
+ const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
+ useEffect(() => {
+ if (!session?.accountID || !conciergeReportID) {
+ return;
+ }
+ const accountID = session.accountID;
+ const tripReportID = '99990002';
+
+ const mockTripRoom = {
+ reportID: tripReportID,
+ type: CONST.REPORT.TYPE.CHAT,
+ reportName: 'NYC Business Trip',
+ chatType: CONST.REPORT.CHAT_TYPE.TRIP_ROOM,
+ ownerAccountID: accountID,
+ currency: 'USD',
+ participants: {[accountID]: {notificationPreference: 'always'}},
+ lastMessageText: 'Trip to Los Angeles',
+ lastActorAccountID: accountID,
+ lastVisibleActionCreated: '2026-07-13 10:00:00.000',
+ tripData: {
+ startDate: '2026-07-15',
+ endDate: '2026-07-20',
+ tripID: 'trip_mock_1',
+ payload: {
+ tripId: 'trip_mock_1',
+ tripName: 'NYC Business Trip',
+ startDateTime: {iso8601: '2026-07-15T08:00:00Z'},
+ endDateTime: {iso8601: '2026-07-20T18:00:00Z'},
+ tripPaymentInfo: {totalFare: {amount: 350, currencyCode: 'USD'}},
+ pnrs: [
+ {
+ pnrId: 'pnr_mock_1',
+ data: {
+ bookingStatus: 'CONFIRMED',
+ pnrTravelers: [],
+ additionalMetadata: {
+ airportInfo: [
+ {airportCode: 'JFK', airportName: 'John F. Kennedy International Airport', cityName: 'New York', stateCode: 'NY', countryName: 'USA'},
+ {airportCode: 'LAX', airportName: 'Los Angeles International Airport', cityName: 'Los Angeles', stateCode: 'CA', countryName: 'USA'},
+ ],
+ airlineInfo: [{airlineCode: 'AA', airlineName: 'American Airlines'}],
+ },
+ airPnr: {
+ legs: [
+ {
+ legStatus: 'CONFIRMED_STATUS',
+ flights: [
+ {
+ origin: 'JFK',
+ destination: 'LAX',
+ departureDateTime: {iso8601: '2026-07-15T08:00:00'},
+ arrivalDateTime: {iso8601: '2026-07-15T11:30:00'},
+ marketing: {airlineCode: 'AA', num: '123'},
+ cabin: 'ECONOMY',
+ flightStatus: 'CONFIRMED',
+ vendorConfirmationNumber: 'MOCK123',
+ duration: {iso8601: 'PT5H30M'},
+ },
+ ],
+ },
+ ],
+ travelerInfos: [
+ {
+ userId: {id: 'traveler_mock_1'},
+ tickets: [{flightCoupons: [{legIdx: 0, flightIdx: 0}]}],
+ },
+ ],
+ },
+ },
+ },
+ ],
+ },
+ },
+ };
+
+ // eslint-disable-next-line rulesdir/prefer-actions-set-data -- temporary local fixture for PR #96283 testing
+ Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${tripReportID}`, mockTripRoom as never);
+
+ // eslint-disable-next-line rulesdir/prefer-actions-set-data -- temporary local fixture for PR #96283 testing
+ Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${tripReportID}`, {
+ '8000000000001': {
+ reportActionID: '8000000000001',
+ actionName: CONST.REPORT.ACTIONS.TYPE.CREATED,
+ actorAccountID: accountID,
+ created: '2026-07-13 10:00:00.000',
+ message: [{type: 'COMMENT', html: 'Trip created', text: 'Trip created'}],
+ },
+ } as never);
+
+ // eslint-disable-next-line rulesdir/prefer-actions-set-data -- temporary local fixture for PR #96283 testing
+ Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${conciergeReportID}`, {
+ '8000000000002': {
+ reportActionID: '8000000000002',
+ actionName: CONST.REPORT.ACTIONS.TYPE.TRIP_PREVIEW,
+ actorAccountID: accountID,
+ created: '2026-07-13 10:00:05.000',
+ message: [{type: 'COMMENT', html: 'Trip preview', text: 'Trip preview'}],
+ originalMessage: {linkedReportID: tripReportID},
+ },
+ } as never);
+ }, [session?.accountID, conciergeReportID]);
+ /* eslint-enable @typescript-eslint/no-unsafe-type-assertion, @typescript-eslint/naming-convention */
+ // ------------------------------------------------------------------
+ // End of mock trip data — REMOVE AFTER TESTING.
+ // ------------------------------------------------------------------
+
useLayoutEffect(() => {
if (!isNavigationReady || !lastRoute) {
return; |
sobitneupane
left a comment
There was a problem hiding this comment.
Reviewer Checklist
- I have verified the author checklist is complete (all boxes are checked off).
- I verified the correct issue is linked in the
### Fixed Issuessection above - I verified testing steps are clear and they cover the changes made in this PR
- I verified the steps for local testing are in the
Testssection - I verified the steps for Staging and/or Production testing are in the
QA stepssection - I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- I verified the steps for local testing are in the
- I checked that screenshots or videos are included for tests on all platforms
- I included screenshots or videos for tests on all platforms
- I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
- I verified tests pass on all platforms & I tested again on:
- Android: HybridApp
- Android: mWeb Chrome
- iOS: HybridApp
- iOS: mWeb Safari
- MacOS: Chrome / Safari
- If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- I verified proper code patterns were followed (see Reviewing the code)
- I verified that comments were added to code that is not self explanatory
- I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
- If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- I verified that this PR follows the guidelines as stated in the Review Guidelines
- I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like
Avatar, I verified the components usingAvatarhave been tested & I retested again) - If a new component is created I verified that:
- A similar component doesn't exist in the codebase
- All props are defined accurately
- The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- The only data being stored in the state is data necessary for rendering and nothing else
- The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- If a new CSS style is added I verified that:
- A similar style doesn't already exist
- The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
- If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avataris modified, I verified thatAvataris working as expected in all cases) - If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
- If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
- I verified that all the inputs inside a form are aligned with each other.
- I added
Designlabel and/or tagged@Expensify/designso the design team can review the changes.
- For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
- If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
Screenshots/Videos
Android: HybridApp
Android: mWeb Chrome
Screen.Recording.2026-07-27.at.23.28.26.mov
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-07-27.at.23.19.52.mov
|
@luacmartins, could you please hold off on merging this for now? I’ll run another round of testing and let you know once it’s ready. Thanks! |
|
@sobitneupane, During testing, I found one more edge case in the trip preview flow. Repro steps:
Screen.Recording.2026-07-29.at.2.28.10.PM.movI’m working on a fix for this case too. Thanks! |
@sobitneupane Addressed this case too. Could you please take another look? Thanks! |
|
@sobitneupane, Gentle bump. thanks. |
|
Reviewing the updates. |
|
@luacmartins, could you please take a look at this, when you get a chance. thanks. |
|
@luacmartins, Gentle bump. thanks. |
|
Sorry, I was OOO. Approved. |
|
@marufsharifi can you merge main please? One workflow seems stuck |
|
🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.4.52-0 🚀
|
|
🤖 I reviewed this PR against the help site articles in Why: This is an internal navigation bug fix. It swaps the hardcoded The travel help articles (e.g. No draft docs PR was created since there's nothing to document. |
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.52-11 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
TripRoomPreviewusedROUTES.REPORT_WITH_IDto navigate when a user tapped a trip reservation item or the "View" button. This route always opens in the Inbox navigator, so users on the Search tab were unexpectedly switched to Inbox. This change replaces the hardcoded route withgetReportRouteForCurrentContext, which returns the correct Search-owned or Inbox-owned route based on the current fullscreen navigator.Fixed Issues
$ #85560
PROPOSAL: #85560 (comment)
Tests
Spend>ChatsOffline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-07-21.at.3.07.52.PM.mov
Android: mWeb Chrome
Recording_20260721_144618.mp4
iOS: Native
Screen.Recording.2026-07-21.at.2.55.59.PM.mov
iOS: mWeb Safari
Screen.Recording.2026-07-21.at.2.57.33.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-07-21.at.2.43.48.PM.mov