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

Copilot - No countdown and code requested message on magic code page when changing access level #55718

Open
6 of 8 tasks
vincdargento opened this issue Jan 24, 2025 · 4 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@vincdargento
Copy link

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.89-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
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+100106kh@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.0 / Chrome
App Component: User Settings

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to Account settings > Security.
  3. Click Add copilot.
  4. Select a user, select access level and proceed to confirmation page.
  5. Click Add copilot.
  6. On magic code page, there is a countdown and "Code requested. Please check your device." message.
  7. Enter correct magic code.
  8. Click on the same member under "These members can access your account".
  9. Click Change access level.
  10. Select a different access level.

Expected Result:

On magic code page when changing access level for existing copilot, it should display a countdown and "Code requested. Please check your device." message.

Actual Result:

On magic code page when changing access level for existing copilot, it does not display a countdown and "Code requested. Please check your device." message, which is not consistent with the magic code page in Step 6.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

@vincdargento vincdargento added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Jan 24, 2025
Copy link

melvin-bot bot commented Jan 24, 2025

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

@etCoderDysto
Copy link
Contributor

etCoderDysto commented Jan 24, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-24 13:48:38 UTC.

Proposal

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

Copilot - No countdown and code requested message on magic code page when changing access level

What is the root cause of that problem?

We have not implemented the timer feature in BaseValidateCodeForm.tsx as we are doing here

/>
<OfflineWithFeedback errorRowStyles={[styles.mt2]}>
<View style={[styles.mt2, styles.dFlex, styles.flexColumn, styles.alignItemsStart]}>
<PressableWithFeedback

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

  1. Create a state to store time and set it to 30 second
    const [timeRemaining, setTimeRemaining] = useState(CONST.REQUEST_CODE_DELAY as number);
  2. Countdown the timer using setTimeOut
    useEffect(() => {
    if (timeRemaining > 0) {
    timerRef.current = setTimeout(() => {
    setTimeRemaining(timeRemaining - 1);
    }, 1000);
    }
    return () => {
    clearTimeout(timerRef.current);
    };
    }, [timeRemaining]);
  3. Show timer when time > 0 and user is not offline (shouldShowTimer)
    const shouldShowTimer = timeRemaining > 0 && !isOffline;
  4. Show resend link when shouldShowTimer is false

{shouldShowTimer && (
<Text style={[styles.mt5]}>
{translate('validateCodeForm.requestNewCode')}

  1. We should reset the timer when requesting a new magic code
setTimeRemaining(CONST.REQUEST_CODE_DELAY);

const resendValidateCode = () => {
if (!login) {
return;
}
Delegate.requestValidationCode();

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A as it is a UI change

What alternative solutions did you explore? (Optional)

We can create hook that returns remainingTime and a function that resets the timer following the same logic as the existing timer implementation.

const {remainingTime, resetTimer} = useRequestTimeout(); 

And use remainingTime to decide if should display timer, and call resetTimer when requesting a new code to reset the time.

Tests

  • remainingTime should be 30 sec when calling the hook
  • remainingTime should be 0 after 30 second
  • remaingTime should be 30 sec when resetTimer is called

@cretadn22
Copy link
Contributor

cretadn22 commented Jan 24, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-24 17:25:44 UTC.

Proposal

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

There’s no countdown and "Code Requested" message displayed on the Magic Code page when changing the access level.

What is the root cause of that problem?

In UpdateDelegateMagicCodePage Component

function UpdateDelegateMagicCodePage({route}: UpdateDelegateMagicCodePageProps) {

We are using an independent ValidateCodeForm (src/pages/settings/Security/AddDelegate/UpdateDelegateRole/ValidateCodeForm/index.tsx), but the code to display the countdown timer has not been implemented

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

Note: In all other instances, we consistently use the ValidateCodeActionModal.

Therefore, I suggest that in the UpdateDelegateMagicCodePage component, we also use ValidateCodeActionModal, as we’ve done in other places like DelegateMagicCodeModal, etc.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

I believe this section is unnecessary

What alternative solutions did you explore? (Optional)

No

Copy link
Contributor

⚠️ @cretadn22 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2
Projects
None yet
Development

No branches or pull requests

4 participants