You need to write them a business-format letter explaining exactly what happened and why you don't owe the amount they claim. Become familiar with the Fair Credit Billing Act. Understand that T-Mobile's warehouse operation is generally very slow to record returns. Many people complain that it takes far too long for to receive credit for phones returned to T-Mobile.
Sorry for the hiccup in the return process, that's certainly not an acceptable outcome.
Have you had a chance to speak directly to a representative and have a handset research form filed?
Just checking in here to see how things are going. We will want to take a closer look at your account and get a research form started if necessary.