Null Propagation Error In Firebase Cloud Function

I just found the optional chaining operator in the MDN docs. From there it seems that it was implement in Node.js version 14, so you're likely using an earlier version either for your Cloud Functions runtime or somewhere in your deployment pipeline.

You'll either have to compile your code down to as supported version, or write the expression fully (which is what a transpiler will do):

if (doc.data() && doc.data().key && doc.data().key.subKey && doc.data().key && doc.data().key.subKey?.subSubKey) { // Do Stuff }