Truncation of the reflection algebra and the Hahn algebra