After upgrade to SQL Server 2019 some stored procedures fail
This looks to be a problem with UDF inlining. As @ScottHodgin suggested, the first step is to install the latest CU to see if the problem persists. If that doesn't resolve the problem, your options are:

Turn off TSQL_SCALAR_UDF_INLINING for the database:
 USE YourDatabase;
 ALTER DATABASE SCOPED CONFIGURATION SET TSQL_SCALAR_UDF_INLINING = OFF;


Add INLINE OFF to the problem function header. This will allow the benefits of scalar inlining for other functions.

Refactor the problem query as to avoid the error.