I’m not sure why you get the error with the format() function.
But the work around for that could be,
Extract the activity where u use the function into a submicroflow.
And give a error handling type continue for the submicroflow.
Since you stated that you are getting the desired output, this would only avoid the error being thrown at the client side.
Add a clause to check for empty values as well, as the function will throw exception if the date passed is empty
You might want to check if the Chat_Owner_Account object exists.
The stacktrace is missing the most important part, that were the error is explained.
But I think Prashant is right in his comment, there should be empty checks.