main ← fix-nested-replies-deleted-topic
merged 06:45PM - 18 May 26 UTC
## Summary
`NestedReplies::TreeLoader#op_post` loaded the OP via `topic.posts`,… whose default scope (from `Trashable`) excludes rows with `deleted_at` set. When a topic is trashed its OP is trashed too, so the lookup returned `nil` and the `/n/...` request crashed in `PostPreloader#prepare` with `undefined method 'user_id' for nil` — preventing staff from reaching the page to recover the topic.
Fix: apply the existing visibility helper (which already unscopes `deleted_at`) on the OP query. The serializer's `deleted_post_placeholder` path preserves content for staff and hides it for everyone else, matching the flat topic view.
- non-staff still 404 via the earlier guardian check on the topic itself, so this does not change their visibility
- both the `show` and `context` endpoints share the same loader, so both paths are fixed
## Test plan
- [x] `bin/rspec spec/requests/nested_topics_controller_spec.rb` (100 examples, 0 failures), with new cases for staff `show`, staff `context`, and non-staff 404 on a fully-deleted topic
- [x] `bin/rspec spec/lib/nested_replies/ spec/services/nested_topic/` (127 examples, 0 failures)
- [ ] Manually: as admin, delete a topic that uses nested replies, then navigate to `/n/<slug>/<id>` — page renders with the deleted OP placeholder and the admin menu's Recover Topic action works