Best practice for information on task list in time entries

What is the best way to get the information which tasks list contains the tasks for the current time entry? I can get the taskId, the parentTaskId but no information about the tasks list. Is it possible to get it via a nested query?

Hi @Christian.Lenz,

i think the easiest way would be something like this:

// Step 1: Get current time entries data
const getTimeEntries = () => {
  const timeEntriesUrl = 'api/v1/timeentries';
  
  // Placeholder for API call result
  const timeEntries = [
    { id: "time1", taskId: "123e4567-e89b-12d3-a456-426614174000", duration: 3600 },
    { id: "time2", taskId: "223e4567-e89b-12d3-a456-426614174000", duration: 1800 }
  ];
  
  // Step 2: Extract unique taskIds from time entries
  const taskIds = [];
  for (const entry of timeEntries) {
    if (entry.taskId && !taskIds.includes(entry.taskId)) {
      taskIds.push(entry.taskId);
    }
  }
  
  if (taskIds.length === 0) {
    console.log('No tasks found in time entries');
    return [];
  }
  
  // Step 3: Build filter query for fetching tasks
  let filterQuery = '';
  for (let i = 0; i < taskIds.length; i++) {
    if (i > 0) {
      filterQuery += ' or ';
    }
    filterQuery += `id eq guid'${taskIds[i]}'`;
  }
  
  const tasksUrl = `api/v1/allAvailableTasks?filterby=${encodeURIComponent(filterQuery)}`;
  
  // Step 4: Get tasks data
  // Placeholder for tasks API call result - sample based on your model
  const tasks = [
    {
      id: "123e4567-e89b-12d3-a456-426614174000",
      name: "Create logo concept",
      lists: [
        {
          id: "list123",
          name: "Product and Marketing To-Dos",
          isArchived: false,
          order: 2
        }
      ]
    },
    {
      id: "223e4567-e89b-12d3-a456-426614174000",
      name: "Another task",
      lists: [
        {
          id: "list456",
          name: "Design Tasks",
          isArchived: false,
          order: 1
        }
      ]
    }
  ];
  
  // Step 5: Associate time entries with their task list information
  const timeEntriesWithListInfo = [];
  
  for (const entry of timeEntries) {
    let matchingTask = null;
    for (const task of tasks) {
      if (task.id === entry.taskId) {
        matchingTask = task;
        break;
      }
    }
    
    const taskLists = [];
    if (matchingTask && matchingTask.lists) {
      for (const list of matchingTask.lists) {
        taskLists.push({
          listId: list.id,
          listName: list.name,
          isArchived: list.isArchived,
          order: list.order
        });
      }
    }
    
    const entryWithLists = { ...entry, taskLists: taskLists };
    timeEntriesWithListInfo.push(entryWithLists);

Does that help?
If you have more than 1000 items, you also need to add paging to the task and timeentries endpoints.

THX, @Nils , that gives me some direction.