Context here: https://phab.comm.dev/D10784#inline-66023.
This code provides functions that handle resetting the user state after migration failure. As a result, this code should also cause the deletion database and clear auth metadata.
Right now this code causes logging out - recovering on native is tracked in [ENG-6546](https://linear.app/comm/issue/ENG-6546/native-handler-component-to-transparently-re-auth-with-identity).
Why do we need different `nonUserSpecificFields` here:
The result of `handleReduxMigrationFailure` is passed directly to the REHYDRATE action, and redux does not merge modified keys with the default state. And we have this flow:
1. `redux-persist` rehydrates only persisted state - not full `AppState`
2. We call this code on the failure, it goes through the state and [reasign](https://github.com/CommE2E/comm/blob/25526c596bb4b8e3fd3cb15c589ea42c5fb79168/lib/utils/reducers-utils.js#L18) `nonUserSpecificFields`.
3. If the field is `nonUserSpecificFields` but it hasn't persisted it gets overridden with `undefined` - an example is `loadingStatuses`.
4. REHYDRATE action skips e.g. `loadingStatuses` because it was modified without merging with default state.
5. We end up with `loadingStatuses: undefined` which is not what is described by types and causes errors in selectors.
To mitigate that, in this particular case when we reset the state after a failed migration we want to reset **only** persisted fields, for others we should use default ones (those are always used as default on app start).
Not sure if this is the cleanest solution but couldn't think of anything better.