There are chances that you might be refused a plan or a device If you have bad credit with T-mobile. If that happens, you can get the phone unlocked somewhere else and then use it with their network through the BYOP option.
This will only be done if your device is compatible with t-mobile. So make sure you check it.