The first one, "had stolen," is grammatically correct. Many native speakers use both versions, however, especially in speech. You're more likely to see the correct form in writing.
By the way, the tense isn't really because of the type of conditional. It's because of the actual sequence of events. The person stole your identity *before* you discovered that they had stolen it. The act of stealing happened further in the past.
If the two events happened at the same time, it would be correct to put them both in past tense. "What would you do if you discovered that your friend was in jail?" You use past tense for "was in jail" if the person was in jail at the time when you discovered it. You should only use "had been in jail" if the person had already been released from jail by the time you discovered it.