Skip to content

fix: Use BC resources directly for teammate timesheet view (#189)#190

Draft
akash2017sky wants to merge 1 commit into
mainfrom
fix/189-timesheet-entries-not-visible
Draft

fix: Use BC resources directly for teammate timesheet view (#189)#190
akash2017sky wants to merge 1 commit into
mainfrom
fix/189-timesheet-entries-not-visible

Conversation

@akash2017sky
Copy link
Copy Markdown
Contributor

Closes #189

Summary

  • Teammate dropdown on the Time tab now fetches BC resources (where useTimeSheet=true) instead of employees — resources are the entities that own timesheets, so we can fetch them by resource.number directly.
  • getTeammateEntries no longer relies on getResourceByEmail, which silently failed whenever an employee's email was missing or its local-part didn't match the resource's timeSheetOwnerUserId convention.
  • Same pattern already used on the Team page (TeamList.tsx), so this brings the two views into agreement.

Root cause

getTeammateEntries called bcClient.getResourceByEmail(teammate.email), which forwards to getResourceForCurrentUser. That helper derives a BC User ID by uppercasing the part before @ and filters resources by timeSheetOwnerUserId. It works for the logged-in user (their UPN follows the convention) but is unreliable for teammates pulled from /employees. When the lookup returned null, the function returned [] — the empty state seen in the bug report.

Test plan

  • Type check passes (bun run typecheck)
  • Verified locally: own timesheet still loads
  • Verify locally: selecting a teammate from the dropdown loads their timesheet entries
  • Verify "(My Name)" still appears next to "My Timesheet" in the dropdown
  • Verify dropdown hides when the user is the only resource with useTimeSheet=true

Notes

  • The teammate read-only banner now shows the resource number (BC code) instead of jobTitle, since jobTitle is an employee-only field.
  • getResourceByEmail is still in bcClient.ts (used by TeamList.tsx for the current user's own resource); not removing it in this PR to keep the change focused.

🤖 Generated with Claude Code

Teammate selector was fetching BC employees and trying to map each
back to a resource via getResourceByEmail, which derives a BC User ID
from the email's local-part. That mapping fails whenever the employee
record has no email or its prefix doesn't match the resource's
timeSheetOwnerUserId convention, leaving the timesheet silently empty.

Switch the dropdown to fetch resources (where useTimeSheet=true) and
fetch the timesheet directly via resource.number — same pattern the
Team page already uses.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Timesheet entries are not visible on the Time screen

1 participant