A message about an invalid code is usually related to using an incorrect activation link. Please make sure you are using the correct activation link:
If you are connecting your TV provider to the app, enter your code at history.com/activate.
If you are creating or syncing a profile (to continue watching on different devices), enter your code at history.com/register.