Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2024-08-09] [$250] Switch to expensify classic button not working on m-web safari #45941

Closed
1 of 6 tasks
m-natarajan opened this issue Jul 22, 2024 · 18 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Jul 22, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.10-6
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @ishpaul777
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1721668187994169

Action Performed:

  1. Go to https://staging.new.expensify.com/settings/exit-survey/reason on mweb
  2. Complete the flow
  3. Click green Switch to Expensify Classic button

Expected Result:

User is redirected to olddot

Actual Result:

User is not redirected to olddot and button nonfunctional

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Screen.Recording.2024-07-22.at.8.51.47.PM.mov
RPReplay_Final1721677493.MP4

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01550410ab679e7457
  • Upwork Job ID: 1815808508017223645
  • Last Price Increase: 2024-07-23
  • Automatic offers:
    • akinwale | Reviewer | 103303782
Issue OwnerCurrent Issue Owner: @abekkala
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 22, 2024
Copy link

melvin-bot bot commented Jul 22, 2024

Triggered auto assignment to @abekkala (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@nyomanjyotisa
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Switch to expensify classic button not working on m-web safari

What is the root cause of that problem?

The root cause of the issue is that the Linking.openURL method in React Native is not handling the URL correctly on Safari. Specifically, Safari has stricter URL handling requirements, and URLs need to be properly encoded to ensure they are opened correctly.

const asyncOpenURL: AsyncOpenURL = (promise, url) => {
if (!url) {
return;
}
promise.then((params) => {
Linking.openURL(typeof url === 'string' ? url : url(params));
});
};

What changes do you think we should make in order to solve the problem?

To address the issue, the following changes are proposed:

  • Ensure that the URL passed to Linking.openURL is properly encoded. This prevents any special characters in the URL from causing issues in Safari.
  • Modify the asyncOpenURL function to encode the URL before opening it with Linking.openURL

Update this code to the following

    promise.then((params) => {
        const finalURL = typeof url === 'string' ? url : url(params);
        const encodedURL = encodeURIComponent(finalURL);
        Linking.openURL(encodedURL);
    });

RESULT

Switch-to-expensify-classic-button-not-working-on-m-web-safari-.-Issue-45941-.-Expensify-App.mp4

What alternative solutions did you explore? (Optional)

@bernhardoj
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Switch to expensify classic doesn't work in mWeb Safari.

What is the root cause of that problem?

Pressing the switch to expensify classic button will do an API request and will try to open the old dot link after the promise is resolved.

onPress={() => {
ExitSurvey.switchToOldDot().then(() => {
if (NativeModules.HybridAppModule) {
Navigation.resetToHome();
NativeModules.HybridAppModule.closeReactNativeApp();
return;
}
Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX);
});

However, opening a link/new tab inside a promise doesn't work on mWeb Safari. We previously had this kind of issue at #3615 which we fix it by opening a new window first then wait for the promise to complete.

const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (!isSafari || shouldSkipCustomSafariLogic) {
promise.then((params) => {
Linking.openURL(typeof url === 'string' ? url : url(params));
});
} else {
const windowRef = window.open();
promise
.then((params) => {
if (!windowRef) {
return;
}
windowRef.location = typeof url === 'string' ? url : url(params);
})
.catch(() => windowRef?.close());

The issue is that in mWeb Safari, opening a new tab/link requires a user gesture, and putting it inside a promise won't be considered a user gesture anymore.

What changes do you think we should make in order to solve the problem?

Call Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX); outside of the promise (we can do it only for mWeb Safari).

onPress={() => {
ExitSurvey.switchToOldDot().then(() => {
if (NativeModules.HybridAppModule) {
Navigation.resetToHome();
NativeModules.HybridAppModule.closeReactNativeApp();
return;
}
Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX);
});

if (!NativeModules.HybridAppModule) {
    Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX);
}

If we only do it in safari, then pressing the Switch to expensify classic will immediately open the new window, while for other platforms, we will wait until the loading is complete.

What alternative solutions did you explore? (Optional)

The main solution will open the window and set the old link link as the url to the window without waiting the switchToOldDot request to complete. If we want to wait for switchToOldDot, then we can update openOldDotLink to accept a new params called extraPromise. We pass the switchToOldDot to the extraPromise and wait for it to complete.

if (!NativeModules.HybridAppModule) {
    Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX, ExitSurvey.switchToOldDot());
} else {
    ExitSurvey.switchToOldDot().then(() => {
        Navigation.resetToHome();
        NativeModules.HybridAppModule.closeReactNativeApp();
    });
}

// If shortLivedAuthToken is not accessible, fallback to opening the link without the token.
asyncOpenURL(
// eslint-disable-next-line rulesdir/no-api-side-effects-method
API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_OLD_DOT_LINK, {}, {})
.then((response) => (response ? buildOldDotURL(url, response.shortLivedAuthToken) : buildOldDotURL(url)))
.catch(() => buildOldDotURL(url)),
(oldDotURL) => oldDotURL,
);

extraPromise.then(() => 
    API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.OPEN_OLD_DOT_LINK, {}, {})
        .then((response) => (response ? buildOldDotURL(url, response.shortLivedAuthToken) : buildOldDotURL(url)))
        .catch(() => buildOldDotURL(url))
),

@abekkala abekkala added the External Added to denote the issue can be worked on by a contributor label Jul 23, 2024
Copy link

melvin-bot bot commented Jul 23, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01550410ab679e7457

@melvin-bot melvin-bot bot changed the title Switch to expensify classic button not working on m-web safari [$250] Switch to expensify classic button not working on m-web safari Jul 23, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 23, 2024
Copy link

melvin-bot bot commented Jul 23, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @akinwale (External)

@akinwale
Copy link
Contributor

After reviewing both proposals, we can move forward with @bernhardoj's proposal here since the solution follows a pattern that already exists in the codebase.

🎀👀🎀 C+ reviewed.

Copy link

melvin-bot bot commented Jul 26, 2024

Triggered auto assignment to @srikarparsi, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot added Overdue and removed Help Wanted Apply this label when an issue is open to proposals by contributors labels Jul 29, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

📣 @akinwale 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@srikarparsi
Copy link
Contributor

Not overdue

@bernhardoj
Copy link
Contributor

PR is ready

cc: @akinwale

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 2, 2024
@melvin-bot melvin-bot bot changed the title [$250] Switch to expensify classic button not working on m-web safari [HOLD for payment 2024-08-09] [$250] Switch to expensify classic button not working on m-web safari Aug 2, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 2, 2024
Copy link

melvin-bot bot commented Aug 2, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Aug 2, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.15-9 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-08-09. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Aug 2, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@akinwale] The PR that introduced the bug has been identified. Link to the PR:
  • [@akinwale] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@akinwale] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@akinwale] Determine if we should create a regression test for this bug.
  • [@akinwale] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@abekkala] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@abekkala
Copy link
Contributor

abekkala commented Aug 2, 2024

PAYMENT SUMMARY FOR AUG 09, if no regressions

@akinwale
Copy link
Contributor

akinwale commented Aug 3, 2024

  • [@akinwale] The PR that introduced the bug has been identified. Link to the PR:
  • [@akinwale] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@akinwale] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:

Not a regression.

  • [@akinwale] Determine if we should create a regression test for this bug.
  • [@akinwale] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

Regression Test Steps

  1. Launch Expensify on Safari on iOS
  2. Navigate to Settings then select Switch to Expensify Classic
  3. Complete the survey
  4. Tap the Switch to Expensify Classic button
  5. Verify that a new tab opens and loads the Old Dot URL

Do we agree 👍 or 👎?

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Aug 8, 2024
@bernhardoj
Copy link
Contributor

Requested in ND.

@abekkala
Copy link
Contributor

abekkala commented Aug 9, 2024

@akinwale payment sent and contract ended - thank you! 🎉

Thank you @bernhardoj

Closing

@abekkala abekkala closed this as completed Aug 9, 2024
@melvin-bot melvin-bot bot removed the Overdue label Aug 9, 2024
@JmillsExpensify
Copy link

$250 approved for @bernhardoj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

7 participants