score:1

Accepted answer

add some parenthesis around those two expressions with the || between them if they should be evaluated together.

((user.userid && user.otpverified) || (user.userid && user.loginwithpassword))

this change makes your login component show based on the values.

you can remove the inner ones too and the && will be evaluated first.

(user.userid && user.otpverified || user.userid && user.loginwithpassword)

else if (
    (user.userid && user.otpverified || user.userid && user.loginwithpassword)
    && !user.profilecompleted
    && match.path === '/complete-profile'
)

https://developer.mozilla.org/en-us/docs/web/javascript/reference/operators/logical_and#operator_precedence

console.log((true && true) || (true && false) && false && false) //true
console.log((true && true || true && false) && false && false) // false

Related Query

More Query from same tag