The line you highlighted was working fine. The issue was with String.IsNullOrWhitespace() returning true even when the object was System.DBNull. There was no MyPageTypeString in that particular page but all the sudden that isnull method started returning true.
I never did figure out why; what I ended up having to do was stop using string.IsNullOrWhitespace(MyPageTypeString) and instead manually do this
if (CurrentDocument.GetValue("MyPageTypeString", "").ToString("") != "") { //run conditional code }
I have yet to figure out why this happened. I didn't change anything else in the app. No idea why I had to change it like this, but it's working now