Skip to content

Aditya - Fix incorrect numbers of Total Projects on the Project page - #5484

Open
AdiDubbs wants to merge 1 commit into
developmentfrom
Aditya_fix_total_projects_count
Open

Aditya - Fix incorrect numbers of Total Projects on the Project page#5484
AdiDubbs wants to merge 1 commit into
developmentfrom
Aditya_fix_total_projects_count

Conversation

@AdiDubbs

@AdiDubbs AdiDubbs commented Aug 30, 2026

Copy link
Copy Markdown

Description

On the Projects page, Total Projects changed depending on which view was open. It read 1189 in the default view and 458 after clicking Show Archived, when it should stay constant at the combined total of 1647. The second card also kept its "Active Projects" label in the archived view.

Original task

Screenshot 2026-08-29 at 8 02 50 PM

Note: the figures above are from Main. On the dev database there are 1189 active and 458 archived, so the expected total here is 1647. The behaviour is the same.

Related PRS (if any):

None. No backend changes.

Main changes explained:

  1. The cause. Both figures were counted from state.allProjects.projects, and fetchAllArchivedProjects dispatched the same FETCH_PROJECTS_SUCCESS as fetchAllProjects, which replaces that array. Toggling the archived view therefore swapped the contents of the single list the counts were reading from. The counts were correct for whatever happened to be in the store; the store was the problem.
  2. Added FETCH_ARCHIVED_PROJECTS_SUCCESS and a matching archivedProjects key on the reducer, so the archived fetch no longer overwrites projects. That key is read by AddTaskModal, UserProfile, UserProfileAdd, UserProfileEdit, Reports and the WBS hook, so it should keep meaning "not archived".
  3. Both lists are fetched on mount, so the total is right before the archived view is ever opened.
  4. Total is now projects.length + archivedProjects.length, which does not change with the view. The project list itself reads from whichever array matches the current view.
  5. Overview takes a label and a count for the second card, so it reads "Archived Projects" with the archived count when that view is open, and "Active Projects" otherwise. Added an ARCHIVED_PROJECTS label alongside the existing ones.
  6. Added two reducer tests covering that neither list overwrites the other.

How to test:

  1. Check out this branch, run npm install, then npm run start:local
  2. Start the backend: redis-server --daemonize yes, then npm run dev in HGNRest
  3. Clear site data and cache
  4. Log in as an Owner or Administrator, then open /permissions once so the role list loads
  5. Go to Other Links → Projects
  6. Note Total Projects and Active Projects
  7. Click Show Archived. Total Projects should be unchanged, and the second card should now read Archived Projects with the archived count
  8. Click Hide Archived. Total should still be unchanged, and the second card should read Active Projects again
  9. Confirm the table still lists the right rows in each view — non-archived by default, archived after toggling
  10. Repeat 5–9 in dark mode
  11. Run npm run test:changed

Screenshots or videos of changes:

Light mode

Before After
Default view — Total Projects: 1189

Default view before the fix, total reads 1189
Default view — Total Projects: 1647

Default view after the fix, total reads 1647
Archived view — total drops to 458, second card still says "Active Projects"

Archived view before the fix, total drops to 458
Archived view — total holds at 1647, second card reads "Archived Projects: 458"

Archived view after the fix, total holds at 1647 and the label reads Archived Projects

Dark mode

Default view Archived view
Total Projects: 1647, Active Projects: 1105

Default view in dark mode after the fix
Total Projects: 1647, Archived Projects: 458

Archived view in dark mode after the fix

Note:

While tracing this I checked whether the archived list overwriting projects caused problems elsewhere. It largely does not: UserProfile and Reports both refetch unconditionally on mount, and AddTaskModal, which is guarded and would read the stale list, only looks up the current project's category and falls back to fetching that project's detail when it is not found. So the worst case there was a redundant request rather than a wrong value. Raising it here for the record rather than as a separate bug, since there is no symptom a user could report.

Total Projects counted whatever list was currently in the store, and the
archive toggle replaced that list rather than adding to it, so the figure
changed from 1189 to 458 simply by switching views. It should stay constant
at the combined total in both.

Archived projects now load into their own key rather than overwriting
`projects`, which several other components read. Both lists are fetched on
mount so the total is right before the archived view is ever opened, and the
second card switches between the active and archived counts with a matching
label.

- Add FETCH_ARCHIVED_PROJECTS_SUCCESS so the archived fetch stops clobbering
  `projects`
- Hold archived projects under `archivedProjects` in allProjectsReducer
- Total is now projects + archivedProjects; the list reads from whichever
  array matches the current view
- Overview takes a label and count for the second card, so the archived view
  reads "Archived Projects" rather than "Active Projects"
- Add ARCHIVED_PROJECTS label
- Two reducer tests covering that neither list overwrites the other
@netlify

netlify Bot commented Aug 30, 2026

Copy link
Copy Markdown

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit fbfb6ab
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6a939b993171b900081193df
😎 Deploy Preview https://deploy-preview-5484--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud

Copy link
Copy Markdown

@AdiDubbs
AdiDubbs marked this pull request as ready for review August 30, 2026 03:12
@iAbhi001
iAbhi001 self-requested a review August 30, 2026 04:04

@iAbhi001 iAbhi001 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review & Approval

I tested this PR locally on the Aditya_fix_total_projects_count branch. Everything functions as expected.

Testing Details:

  1. Default View:
  • Total Projects correctly displays 1647 (projects.length + archivedProjects.length).
  • The second card correctly renders Active Projects: 1105.
  • The project list table renders active projects.
  1. Archived View ("Show Archived"):
  • Total Projects remains constant at 1647 and does not drop.
  • The second card dynamically updates its label and count to Archived Projects: 458.
  • The project list table displays archived projects with the unarchive action available.
  1. Toggle Back ("Hide Archived"):
  • Counts and labels smoothly revert to the active state without redundant re-renders or layout shifts.
  • Tested under dark mode—styling, contrast, and card alignments look clean and consistent.
  1. Automated Tests:
  • Ran npm run test:changed and the reducer tests passed with no regressions.

Great job isolating the reducer state with FETCH_ARCHIVED_PROJECTS_SUCCESS and archivedProjects to prevent store overwrites.

LGTM! Approved. 🚀

Image Image

@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Aug 31, 2026

@DeMoliT1on DeMoliT1on left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally for frontend PR changes branch Aditya_fix_total_projects_count and observed the following things.

Overall Assessment

Verified Working

  • Total Projects Count: Stays constant at 1647 across both views.
  • Dynamic Second Card Label: Displays "Active Projects: 1105" by default and switches to "Archived Projects: 458" when viewing archived projects.
  • View Toggle Behavior: Switching via "Show Archived" / "Hide Archived" updates the project list context without corrupting global project counts.
  • Theme Support: UI layout, button styling, and badge text render consistently across light and dark themes.

Screenshots

Image Image Image Image

The PR successfully resolves the count mutation bug by separating active and archived project state keys. All requested test steps were verified locally in both light and dark modes with expected UI behavior. Approved!

@DeepighaJ DeepighaJ left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Verified the Projects page functionality as per the testing requirements.
  • Confirmed that Total Projects remains unchanged when toggling between Show Archived and Hide Archived, while the second card correctly switches between Active Projects and Archived Projects with the appropriate count.
  • Also verified that the table displays the correct non-archived and archived rows in each respective view.
Image Image

Dark mode:

  • The Show Archived button displays with a white/light background, which does not match the dark mode styling of the page. Please update the button styling to ensure it is consistent and readable in dark mode.
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants