[Bug] url redirect not operating as expects from inside a discussion thread

i noticed a bug with the logic used for the url. In the category it works fine, but if for example i click calendar on this thread it tries to open this page:

https://publichappinessmovement.com/t/topic/2565/343/l/calendar

when it should go back into the category or sub category the thread lives in and then open a calendar. In this case it would be:

h t t p s://publichappinessmovement.com/c/teams/web-developers/floating-footer/149/l/calendar