Weekly running distance

I want to calculate the running distance in the current week by UserProfile.getUserActivityHistory, with the filtering of 'Toybox.UserProfile.UserActivity.startTime'. This works on my fr255, but the code returns 0 on some users' watch (Enduro, Fenix 6x).  It seems like either the 'startTime' is null or wrong. Am I doing something wrong?  Thanks.

    function getStartOfWeek() as Moment {
        var today = new Time.Moment(Time.today().value());
        var info = Gregorian.info(today, Time.FORMAT_SHORT);
        var firstDayOfWeek = 1;

        var settings = System.getDeviceSettings();
        if (settings has :firstDayOfWeek) {
            firstDayOfWeek = settings.firstDayOfWeek as Number;
        }
        var days = info.day_of_week as Number - firstDayOfWeek;
        if (days < 0) {
            days += 7;
        }

        return today.subtract(new Time.Duration(days * 86400)) as Moment;
    }

    // Running distance in m
    function getWeeklyDistance() as Number {
        var dist = 0 as Number;

        if (UserProfile has :getUserActivityHistory) {
            var itr = UserProfile.getUserActivityHistory();
            if(itr != null){
                var next = itr.next();
                var weekStart = getStartOfWeek();
                
                while (next != null) {
                    if (next.type == Activity.SPORT_RUNNING && next.distance != null){
                        if (next.startTime != null && weekStart.lessThan(next.startTime as Moment)) {
                            dist += next.distance as Number;
                        }
                    }
                    next = itr.next();
                }
            }
        }
        return dist;        
    }