A general rule of thumb is to always make sure you're below treeline by the time a thunderstorm rolls through. With this rule in mind, it can be okay to take on a short hike in the afternoon in the park if it's a hike that stays below treeline the whole time. An example of this would be in you didn't get a timed entry permit and so now you're waiting until 6pm to enter the park, but it's a short hike to just Alberta Falls or Dream, which both stay under treeline, so dependent on the forecasted chance of precipitation and thunder, you could go for it.