[EDIT 6 August, 2021] The issue is fixed in version 40.1. Please update to this version to enable the Raid Battle History Team Viewing feature for your game.
We have investigated performance issues with the implementation of viewing the team used to attack you in Raids and we're currently working on a fix. To ensure game stability until the patch is rolled out, we have temporarily disabled this feature.
In the meantime, we will continue to update this announcement with further information.
Please accept our sincerest apologies for any inconvenience caused by this!