Make sure invitation has a code before trying to access it

I'm not sure how I managed to hit a condition in which there was an invitation without a code but I did. Perhaps checking for existence is a good idea?