Hello,
When I run the addDataFromPath command, python prints "<arcpy._mp.Layer object at 0x000002658CF55948>" rather than adding anything to the map. I have 'arcpy.env.addOutputsToMap' set to 'True'
Here is a sample of my script:
layer_name = "layer"
Input_gdb = "gdb"
aprx = arcpy.mp.ArcGISProject(InputProject)
m = aprx.listMaps('Map')[0]
m.addDataFromPath(Input_gdb + "\\" + layer_name)
check the code examples
Map—ArcGIS Pro | Documentation
If the code is as you show it, then layer_name and input_gdb won't be known