def IsTryJobResultAtRevisionValidForStep(result_at_revision, step_name):
  """Checks if a flake try job result is valid.

  Args:
    result_at_revision (dict): The result of running at a revision. For example,
      {
         'browser_tests': {
              'status': 'failed',
              'failures': ['TabCaptureApiTest.FullscreenEvents'],
              'valid': True,
              'pass_fail_counts': {
                  'TabCaptureApiTest.FullscreenEvents': {
                      'pass_count': 28,
                      'fail_count': 72
                  }
              },
              'step_metadata': {
                  'task_ids': [],
                  ...
              }
          }
      }
    step_name (str): The name of the step, assumed to be in result_at_revision.

  Returns:
    Whether the results are valid based on the 'valid' field.
  """
  # step_name is assumed to be in result_at_revision for valid use of this
  # function.
  if not result_at_revision or step_name not in result_at_revision:
    return False

  return result_at_revision[step_name]['valid']