code: func fillShallowInvs(c context.Context, invs []*Invocation, opts ListInvocationsOpts) ([]*Invocation, error) {
  	var shallow []*Invocation
  	for _, inv := range invs {
  		if inv.Status == "" {
  			shallow = append(shallow, inv)
  		}
  	}
  	if len(shallow) == 0 {
  		return invs, nil
  	}
  
  	if err := datastore.Get(c, shallow); err != nil {
  		return nil, errors.Annotate(err, "failed to fetch invocations").Tag(transient.Tag).Err()
  	}
  
  	filtered := invs[:0]
  	for _, inv := range invs {
  		if opts.ActiveOnly && inv.Status.Final() {
  			continue
  		}
  		if opts.FinishedOnly && !inv.Status.Final() {
  			continue
  		}
  		filtered = append(filtered, inv)
  	}
  	return filtered, nil
  }
docs: // fillShallowInvs detects entities that do not have bodies fetched yet, fetches
  // them, and filters them based on ActiveOnly/FinishedOnly filter defined by
  // opts.
  //
  // This is needed for results of queries that use IDs inlined in the Job entity.
  // We detect such shallow entities by missing Status value, which is guaranteed
  // to be set for all Invocation entities.
  //
  // Filtering is required since the state of the entities fetched here may be
  // more up-to-date than the state used by queries. In particular, active
  // invocations may not be active anymore.
  //
  // Filters the given slice in-place and returns the filtered slice that shares
  // the same underlying array.