T-Mobile unlocks their devices. Above is the link to the DOC that shows all the rules you need to have completed.
They're similar to the rules to the other carriers. More lenient in many instances, I've heard in these forums.
Personally, I've never had a problem getting a device unlocked. And every phone I've purchased from T-Mobile, I've had unlocked by them.
As a recent ATT customer, I have to disagree. The ATT customer forums are full of people complaining that they can't get their phones unlocked. ATT has some strict requirements that many (especially the pre-paid customers; 6 continuous months of service) overlook. The worse case is when an ATT customer ports to another carrier and has to wait for their final bill (and pay it) before they can get their phone unlocked. This results in lots of customers not having a device to use on their new carrier for as long as 4 weeks.
It's ridiculous. I've been trying to get my paid for iphone6 unlocked for WEEKS. Every phone call is a different excuse. Oh you have a balance. Nope. Oh it's in a different database. Whatever. Oh we sent the unlock code to a different email. Oops. Oh there IS NO unlock code. What??? I had to leave Tmobile because of dropped calls. Now they are basically holding my phone hostage. I will make sure I let everyone know NOT to use tmobile because of this. I now have a $600 paperweight.
I can understand your frustration.
Since I don't use an iphone, I don't have any direct help to offer you. It seems that iphones have specific unlocking procedures that differ from unlocking Android devices. There are a lot of discussions about the unique characteristics of the iphone unlocking procedures. If you search using the magnifying glass at the top of this page you will discover the wealth of accurate info that exists pertaining to the topic. I used the query > Unlock iphone <.
You might find solutions in one or more of those discussions while you wait for a response here. You could also start your own thread and be seen by more members with the expertise to help you. You can do that by selecting "Create a discussion" on the "Apple iPhone Discussions" page.