Skip to content

Conversation

@dukenv0307
Copy link
Contributor

@dukenv0307 dukenv0307 commented Sep 3, 2025

Explanation of Change

Fixed Issues

$ #69008
PROPOSAL: #69008 (comment)

Tests

  • Precondition:

Navigate to OldDot staging
Create a new expensifail account
Create a workspace
Open the console and paste this command:
var settings = NVP.get('travelSettings') || {};
settings.testAccount = true;
NVP.set('travelSettings', settings);
Refresh the browser
In workspace settings - set the following Company Address "548 Market St San Francisco, CA 94104, United States"

  1. Open https://staging.new.expensify.com/
  2. Click on FAB button
  3. Click on "Book Travel"
  4. Click on "Book Travel" button
  5. Check box agree to the terms and conditions
  6. Click on "Continue"
  7. Verify that: User is navigated to http://travel.expensify.com in the current tab if it's safari, and in a new tab with other platforms
  • Verify that no errors appear in the JS console

Offline tests

Same as above

QA Steps

Same as above

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover 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 tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • 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 Avatar is modified, I verified that Avatar is 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 Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2025-09-03.at.18.32.58.mov
Android: mWeb Chrome
Screen.Recording.2025-09-03.at.18.27.08.mov
iOS: Native
iOS: mWeb Safari
Screen.Recording.2025-09-03.at.18.24.13.mov
MacOS: Chrome / Safari
Screen.Recording.2025-09-03.at.18.20.22.mov
MacOS: Desktop
Screen.Recording.2025-09-03.at.18.32.07.mov

@dukenv0307
Copy link
Contributor Author

I'm facing this issue on iOS native. I'll try again soon

image

@dukenv0307 dukenv0307 marked this pull request as ready for review September 3, 2025 11:41
@dukenv0307 dukenv0307 requested review from a team as code owners September 3, 2025 11:41
@melvin-bot melvin-bot bot requested review from QichenZhu and removed request for a team September 3, 2025 11:41
@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2025

@QichenZhu 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]

Copy link
Contributor

@trjExpensify trjExpensify left a comment

Choose a reason for hiding this comment

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

It doesn't look like you got a tangible answer on this question in the issue.

@stitesExpensify @rlinoz @Gonals ya'll would be good to chime in here before this PR potentially goes through to redirect to TravelDot in the same tab on mWeb Safari. It sounds like from the code note we don't want that.

@rlinoz
Copy link
Contributor

rlinoz commented Sep 3, 2025

Looking at the original doc/code I see no reason we decided to open a different tab, also cc: @cristipaval in case you know.

@stitesExpensify
Copy link
Contributor

So when we originally implemented travel it was always opened in a new tab. Now the idea is that in the mobile apps it opens inside of the same tab for a more cohesive experience.

Given that this is mobile-web, I think that we could really go either way. If you're using the app in mobile web though I think that it could be frustrating to lose your expensify tab to do travel since there isn't any easy way to get back to expensify once you are on expensify travel

@trjExpensify
Copy link
Contributor

If you're using the app in mobile web though I think that it could be frustrating to lose your expensify tab to do travel since there isn't any easy way to get back to expensify once you are on expensify travel

I agree with this, it seems cumbersome without a clean way back, so I favour a different tab on mWeb.

@dukenv0307
Copy link
Contributor Author

@stitesExpensify @trjExpensify Open in the same tab is the behavior we fix for the Safari mWeb/web, not all platforms. On safari, opening a new tab doesn't work in this case due to pop-up blocking policies

@trjExpensify
Copy link
Contributor

We can't be the only app needing to navigate the need to open a new tab.

cleanupTravelProvisioningSession();

// TravelDot is a standalone white-labeled implementation of Spotnana so it has to be opened in a new tab
Linking.openURL(buildTravelDotURL(travelProvisioning.spotnanaToken, travelProvisioning.isTestAccount ?? false));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@trjExpensify, We opened this in a new tab with logic. But it doesn't work on Safari. The reason is that the navigation logic is called inside a useEffect, not in response to a user interaction, which violates pop-up blocking policies on Safari. So, on Safari, we can only set it to open in the same tab.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can take the navigation logic outside of the useEffect though can't we? So if we want to maintain the consistency of all mWeb/Web browsers always opening a new tab to access TravelDot, that is something we should explore. Would you agree, @stitesExpensify?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can take the navigation logic outside of the useEffect though can't we?

Yes, that's possible. Since we only get the URL after an API call, we can open a blank page first and then redirect once we have the URL. The downside is that users will briefly see a blank page if the API call fails.

Copy link
Contributor

Choose a reason for hiding this comment

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

For my understanding, why can't we keep the user on the terms page with a loading spinner on the confirmation button until we get an API response, and then navigate (or not if it fails)? Isn't that still tied to the user's action?

The downside is that users will briefly see a blank page if the API call fails.

but maybe we're okay to live with this anyway to maintain consistency, especially if it's not super prevalent. I'd be curious for Brandon's take too.

Copy link
Contributor

Choose a reason for hiding this comment

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

For my understanding, why can't we keep the user on the terms page with a loading spinner on the confirmation button until we get an API response, and then navigate (or not if it fails)? Isn't that still tied to the user's action?

This way works for other browsers but not Safari. It will block the new tab if it opens even 1s after the user's action.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't that the same behavior we have in other places that use asyncOpenURL?

Yes, it behaves like other places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, in that case I think we should be consistent and use the same solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Let's use asyncOpenURL, @dukenv0307.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@luacmartins To do with asyncOpenURL solution, we need to change acceptSpotnanaTerms to side effect API to get the response via promise, and then do something like this. Do you agree with this?

onSubmit={() => {
                            if (!hasAcceptedTravelTerms) {
                                setErrorMessage(translate('travel.termsAndConditions.error'));
                                return;
                            }
                            if (errorMessage) {
                                setErrorMessage('');
                            }

                            asyncOpenURL(
                                acceptSpotnanaTerms(domain).then((response) => {
                                    if (response?.jsonCode !== 200) {
                                        return;
                                    }
                                    if (response?.spotnanaToken) {
                                        return buildTravelDotURL(response.spotnanaToken, response.isTestAccount ?? false);
                                    }
                                }),
                                (travelDotURL) => travelDotURL ?? '',
                            )
                            
                        }}
Screen.Recording.2025-09-22.at.22.19.07.mov

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, that's fine. I know it's an anti-pattern in App, but we have exceptions when contacting external APIs like Spotnana's. You can see other usages of asyncOpenUrl also call the API with makeRequestWithSideEffects. Let's just add a comment explaining why we do this.

@dukenv0307
Copy link
Contributor Author

@QichenZhu It's ready for review again

return buildTravelDotURL(response.spotnanaToken, response.isTestAccount ?? false);
}
}),
(travelDotURL) => travelDotURL ?? '',
Copy link
Contributor

Choose a reason for hiding this comment

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

On error it opens a tab of NewDot. It should close the new tab.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already had the logic to close the tab on error here:

.catch(() => {
windowRef?.close();
Log.warn('[asyncOpenURL] error occurred while opening URL', {url});


API.write(WRITE_COMMANDS.ACCEPT_SPOTNANA_TERMS, params, {optimisticData, successData, failureData});
// eslint-disable-next-line rulesdir/no-api-side-effects-method
return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.ACCEPT_SPOTNANA_TERMS, params, {optimisticData, successData, failureData});
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment as @luacmartins asked.

Yea, that's fine. I know it's an anti-pattern in App, but we have exceptions when contacting external APIs like Spotnana's. You can see other usages of asyncOpenUrl also call the API with makeRequestWithSideEffects. Let's just add a comment explaining why we do this.

@luacmartins
Copy link
Contributor

Bump @dukenv0307

@dukenv0307
Copy link
Contributor Author

on it now

@dukenv0307
Copy link
Contributor Author

@QichenZhu Can you please review again?

@codecov
Copy link

codecov bot commented Oct 1, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pages/Travel/TravelTerms.tsx 0.00% 2 Missing ⚠️
src/libs/actions/Travel.ts 0.00% 1 Missing ⚠️
src/libs/asyncOpenURL/index.website.ts 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@QichenZhu
Copy link
Contributor

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 Issues section 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 Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • 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 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
    • MacOS: Desktop
  • 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
    https://github.com/Expensify/App/pull/68205/files#r2394296371
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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 using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 Avatar is modified, I verified that Avatar is 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 Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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 main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
    Unit tests won't catch this since it's browser-specific behavior.
  • 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-native.webm
android-native-error.webm
Android: mWeb Chrome
android-web.webm
android-web-error.webm
iOS: HybridApp
ios-native.mov
ios-native-error.mov
iOS: mWeb Safari
ios-web.mov
ios-web-error.mov
MacOS: Chrome / Safari
mac-web.mov
mac-web-error.mov
MacOS: Desktop
mac-desktop.mov
mac-desktop-error.mov

@melvin-bot melvin-bot bot requested a review from tylerkaraszewski October 1, 2025 13:24
@luacmartins
Copy link
Contributor

@stitesExpensify @tylerkaraszewski all yours

@tylerkaraszewski tylerkaraszewski merged commit 759a4b8 into Expensify:main Oct 3, 2025
22 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Oct 3, 2025

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Oct 3, 2025

🚀 Deployed to staging by https://github.com/tylerkaraszewski in version: 9.2.23-0 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Oct 6, 2025

🚀 Deployed to production by https://github.com/lakchote in version: 9.2.23-3 🚀

platform result
🖥 desktop 🖥 success ✅
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@QichenZhu QichenZhu mentioned this pull request Oct 13, 2025
60 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants