What could be an expression that displays a symbol in the print preview legend only if there are values in the attribute table.
Example:
A point layer has no entries/points. A surface layer has two geometries. In the legend of the print layout, all layers are now displayed by default. Now an expression is to be inserted so that only layers that also have attributes appear in the legend.