The most common reason for an invalid 2FA code is the date or time on the 2FA code generating device is incorrect. Often caused by travelling to another timezone and not updating the device's timezone settings.
To fix this, make sure your device is set to the correct date and time.
If you are using Google Authenticator on an Android device, please make sure that the timezone on your 2FA device is synced correctly by selecting Google Authenticator > Settings > Time Correction for codes > Sync Now.
If this does not work, let us know and we can disable 2FA on your account. (https://www.bitmex.com/app/support/contact)