Show only features within current Atlas feature - QGIS 3

Whilst teaching about map composer and atlas we wanted to show features that are within a polygon extent. A quick google search showed us that this had been answered by Underdark but her answer included showing intersecting features. In our case, we only wanted to show features that were within a polygon.

I initially tried to use the solution that had been suggested by Underdark but the results were unsatisfactory. After trying the Underdark solution I could get the following result:

Then I thought I could just do an intersection between the Atlas geometry and the feature geometry I wanted. This solution does not work because QGIS returns a geometry collection and apparently QGIS cannot handle it properly.

The solution I finally came up with included the earlier solution from Underdark.