Are you trying to do this as a formula? I'm not sure what the results would be if you did.
But I do something like this already. Actually it's the truncated name of the parent project with the right type. With our setup it may be the parent, the parent's parent or even the parent's parent's parent. So this proves it can be quite robust.
I create this name as the result of a custom action that we use to create structured subprojects
I also just tested your forumula:
And it works fine as a Custom Action. So you've done it correctly.
So a better bet - I do a similar thing to combine two fields that is triggered as a workflow rule when the name of the project changes (or first time) which might be closer to what you need.