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-10-25] Contact method - unlinkLoginForm.succesfullyUnlinkedLogin after unlinking secondary login #50256

Closed
2 of 6 tasks
lanitochka17 opened this issue Oct 4, 2024 · 41 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

@lanitochka17
Copy link

lanitochka17 commented Oct 4, 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.44-7
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): applausetester+kh021001@applause.expensifail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to Account settings > Profile > Contact method
  3. Click New contact method
  4. Add a secondary email and enter magic code, but do not verify it
  5. Log in as the secondary email
  6. Click Unlink
  7. Open email with subject "Unlink secondary Expensify login"
  8. Click on the link "the validation link here"

Expected Result:

App will show the correct successful unlink message

Actual Result:

App shows unlinkLoginForm.succesfullyUnlinkedLogin after unlinking secondary login

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

Add any screenshot/video evidence
Bug6624569_1728055712579.20241004_232118.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @trjExpensify / @trjExpensify
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 4, 2024
Copy link

melvin-bot bot commented Oct 4, 2024

Triggered auto assignment to @trjExpensify (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.

@lanitochka17
Copy link
Author

@trjExpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@twilight2294
Copy link
Contributor

twilight2294 commented Oct 4, 2024

Proposal

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

unlinkLoginForm.succesfullyUnlinkedLogin after unlinking secondary login

What is the root cause of that problem?

We are pasting unlinkLoginForm.succesfullyUnlinkedLogin in the success data here:

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
message: 'unlinkLoginForm.succesfullyUnlinkedLogin',
},

Then in the UnlinkLoginForm below, we check

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

Pass a message prop to unlinkLogin and set it as message of successData, the message can be formed in UnlinkLoginPage here and then sent to the function.

We would also ned to update the message below:

const unlinkMessage = account?.message === 'unlinkLoginForm.linkSent' || account?.message === 'unlinkLoginForm.succesfullyUnlinkedLogin' ? translate(account?.message) : account?.message;
as now we will set the actual message instead of the key

If there is same bug with unlinkLoginForm.linkSent we need to fix that too, also need to check if any BE changes are needed

Implementation:

  • In UnlinkLoginPage, we need to create a new const as UnlinkLoginMessage:
const unlinkLoginMessage = translate('unlinkLoginForm.succesfullyUnlinkedLogin`)

    useEffect(() => {
        Session.unlinkLogin(Number(accountID), validateCode, unlinkLoginMessage);

    }, []);

  • then for unlinkLogin function, we would update it to:
function unlinkLogin(accountID: number, validateCode: string, unlinkMessage: string) {
...
...
...
const successData: OnyxUpdate[] = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: ONYXKEYS.ACCOUNT,
            value: {
                isLoading: false,
                message: unlinkMessage,
            },
        },

What alternative solutions did you explore? (Optional)

@Nodebrute
Copy link
Contributor

Nodebrute commented Oct 4, 2024

Edited by proposal-police: This proposal was edited at 2024-10-04 17:49:43 UTC.

Proposal

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

unlinkLoginForm.succesfullyUnlinkedLogin after unlinking secondary login

What is the root cause of that problem?

We are passing this as a string 'unlinkLoginForm.succesfullyUnlinkedLogin' and we are not using translate here

message: 'unlinkLoginForm.succesfullyUnlinkedLogin',

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

let's use translate here translate('unlinkLoginForm.succesfullyUnlinkedLogin')

message: 'unlinkLoginForm.succesfullyUnlinkedLogin',

Let's fix these two value too translate('unlinkLoginForm.linkSent') and translate('unlinkLoginForm.succesfullyUnlinkedLogin')
const unlinkMessage = account?.message === 'unlinkLoginForm.linkSent' || account?.message === 'unlinkLoginForm.succesfullyUnlinkedLogin' ? translate(account?.message) : account?.message;

We should look for other places too where we are not using translate and fix the issue

Some other places where we should fix this

message: 'resendValidationForm.linkHasBeenResent',

message: 'unlinkLoginForm.linkSent',

Note

We should use the translate method wherever we are using these variables. This will address the issue at its core. Additionally, we have a reviewer checklist item emphasizing the importance of using the translate method with variables.

I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the [translation method](https://github.com/Expensify/App/blob/4bd99402cebdf4d7394e0d1f260879ea238197eb/src/components/withLocalize.js#L60)

What alternative solutions did you explore? (Optional)

Or we can also use Localize.translateLocal in Session/index.ts file and translate in UnlinkLoginForm.tsx file

@Nodebrute
Copy link
Contributor

Proposal Updated
Added another place where the fix is needed

@Nodebrute
Copy link
Contributor

Updated Proposal
Added Alternate solution

@trjExpensify trjExpensify added the External Added to denote the issue can be worked on by a contributor label Oct 4, 2024
Copy link

melvin-bot bot commented Oct 4, 2024

Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 4, 2024
Copy link

melvin-bot bot commented Oct 4, 2024

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

@bernhardoj
Copy link
Contributor

Proposal

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

Unlink login form success message is shown with the translation key.

What is the root cause of that problem?

The message is shown without being translated here.

{(!!closeAccount?.success || !!account?.message) && (
<DotIndicatorMessage
style={[styles.mv2]}
type="success"
// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/prefer-nullish-coalescing
messages={{0: closeAccount?.success ? closeAccount.success : account?.message || ''}}
/>
)}

This happens after #42970. Previously, DotIndicatorMessage handles the translation if it needs translation. So, the account message will always be translated, but not with the closeAccount.success because we mark it as translated already.
image

But after the PR, DotIndicatorMessage will show any message it gets, so the translation responsibility is from the component that uses it.

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

To follow the previous behavior, we need to translate the account.message when passing it down to DotIndicatorMessage.

messages={{0: closeAccount?.success ? closeAccount.success : translate(account?.message) || ''}}

Copy link

melvin-bot bot commented Oct 7, 2024

@rojiphil, @trjExpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Oct 7, 2024
@trjExpensify
Copy link
Contributor

@rojiphil can you review the proposals, please? Thanks!

@Nodebrute
Copy link
Contributor

Proposal Updated
Added a note

@rojiphil
Copy link
Contributor

rojiphil commented Oct 8, 2024

@bernhardoj Is there any distinct advantage of using translate just before display as per your proposal vis-a-vis using it at the source itself as proposed by @Nodebrute

@melvin-bot melvin-bot bot removed the Overdue label Oct 8, 2024
@bernhardoj
Copy link
Contributor

If we save the translated text to Onyx, then changing the app language won't re-translate it. I believe it's a common pattern to save the translation key to Onyx.

@Nodebrute
Copy link
Contributor

@bernhardoj Could you provide any reference where we are saving a translation key to Onyx?

@twilight2294
Copy link
Contributor

@bernhardoj Is there any distinct advantage of using translate just before display as per your proposal vis-a-vis using it at the source itself as proposed by @Nodebrute

@rojiphil FYI, the source is a ts file so we cannot use directly save it there, we need to pass it as a prop

@Nodebrute
Copy link
Contributor

@twilight294 We can use Localize.translateLocal, just like we do in other TypeScript files

return `${Localize.translateLocal('paymentMethodList.accountLastFour')} ${account.accountNumber?.slice(-4)}`;

@bernhardoj
Copy link
Contributor

bernhardoj commented Oct 8, 2024

I was going to refer to the IOU file where there are a lot of getMicroSecondOnyxErrorWithTranslationKey usage such as below,

errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('iou.error.genericCreateFailureMessage'),

but I just realized getMicroSecondOnyxErrorWithTranslationKey translate the key.

function getMicroSecondOnyxErrorWithTranslationKey(error: TranslationPaths, errorKey?: number): Errors {
return {[errorKey ?? DateUtils.getMicroseconds()]: Localize.translateLocal(error)};
}

And again, this happens after #42970. Previously, we saved the translation key (with isTranslated is false, so we know that it needs to be translated).

image image

This means, any errors that use getMicroSecondOnyxErrorWithTranslationKey is not translatable.

image

Btw, here is an example where we translate the key before showing it.

const unlinkMessage = account?.message === 'unlinkLoginForm.linkSent' || account?.message === 'unlinkLoginForm.succesfullyUnlinkedLogin' ? translate(account?.message) : account?.message;

Maybe we should align first whether a client-side error message should be translatable or not.

@Nodebrute
Copy link
Contributor

Nodebrute commented Oct 9, 2024

@bernhardoj The error you mentioned, The provided phone number belongs to landline, is coming from the backend and not from the en.ts/es.ts files. That's why it's not being translated.

@Nodebrute
Copy link
Contributor

Here we set error using getMicroSecondOnyxErrorWithTranslationKey which uses Localize.translateLocal(error) under the hood

errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.taxes.error.createFailureMessage'),

This is the error we get when the create tax rate request fails. It is translated into Spanish, and I believe this is a common pattern that we use in our app.
Screenshot 2024-10-09 at 8 27 28 PM

@puneetlath
Copy link
Contributor

Ah ok. In that case, I agree with you on saving the key and translating at the time of usage. Is that what we do in other similar scenarios?

@rojiphil
Copy link
Contributor

Ah ok. In that case, I agree with you on saving the key and translating at the time of usage. Is that what we do in other similar scenarios?

Well, both approaches are used. But a similar scenario here uses this approach.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 14, 2024
@puneetlath
Copy link
Contributor

Cool, thanks for the explanation. Let's do it.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 15, 2024
@bernhardoj
Copy link
Contributor

PR is ready

cc: @rojiphil

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 18, 2024
@melvin-bot melvin-bot bot changed the title Contact method - unlinkLoginForm.succesfullyUnlinkedLogin after unlinking secondary login [HOLD for payment 2024-10-25] Contact method - unlinkLoginForm.succesfullyUnlinkedLogin after unlinking secondary login Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 18, 2024
Copy link

melvin-bot bot commented Oct 18, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.50-8 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-10-25. 🎊

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

  • @rojiphil requires payment (Needs manual offer from BZ)
  • @bernhardoj requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented Oct 18, 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:

  • [@rojiphil] The PR that introduced the bug has been identified. Link to the PR:
  • [@rojiphil] 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:
  • [@rojiphil] 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:
  • [@rojiphil] Determine if we should create a regression test for this bug.
  • [@rojiphil] 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.
  • [@trjExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@rojiphil
Copy link
Contributor

  • [@rojiphil] The PR that introduced the bug has been identified. Link to the PR: Offending PR
  • [@rojiphil] 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: Added comment
  • [@rojiphil] 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 Required. Existing checklist is good enough to capture such issues.
  • [@rojiphil] Determine if we should create a regression test for this bug. : Yes. We can
  • [@rojiphil] 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.

Steps:

  1. Go to Settings->Profile and add a secondary email.
  2. Login with secondary email and click on Unlink
  3. Open Unlink Validation link email and click on the link
  4. Verify that the unlink success message is displayed.

@rojiphil
Copy link
Contributor

@trjExpensify BZ Checklist is done

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 25, 2024
Copy link

melvin-bot bot commented Oct 25, 2024

Payment Summary

Upwork Job

BugZero Checklist (@puneetlath)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@trjExpensify
Copy link
Contributor

Great, thanks! Payment summary as follows:

@rojiphil sent you an offer. @bernhardoj, go ahead and request.

@rojiphil
Copy link
Contributor

@rojiphil sent you an offer.

Thanks @trjExpensify. Accepted offer.

@trjExpensify
Copy link
Contributor

Perfect, paid!

@bernhardoj
Copy link
Contributor

Requested in ND.

@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
No open projects
Status: Polish
Development

No branches or pull requests

8 participants