I have been facing the same problem and I would say that the problem is not in excel and it is in Testrail page urls and security techniques.
? in the link is the problem this is what I initially thought but I was wrong. Facebook link to photos also contains ? and excel is able to open the correct photo even if the photo ID is after the Question mark.
Hence this proves that the ? in testrail link is not the problem.
And excel is correctly encoding the URL in his system without any error.
Problem clearly lies in the redirection of URL when testrail receives the URL it logs in and authenticate and in the process it forgets where to redirect and directs to dashboard.
While other links can perfectly emulate correctly from testrail even with question mark it proves that the problem clearly lies in Testrail.
Also it shows that it happens only when clicked on excel and not when clicked on outlook. This proves that this combo of link clicked on excel is not received correctly by testrail initially.
Kindly look more into the issue and solve it by improving the URL’s linking.