Open IuliiaHerets opened 3 days ago
Triggered auto assignment to @joekaufmanexpensify (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
@joekaufmanexpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
@BrtqKr It seems this relates to this issue https://github.com/Expensify/App/issues/47014. Could you take a look?
Auto-pay approved reports amount is 0 instead of 100 when enabled for the first time
When user enable Auto-pay approved reports
for the first time, enabled
is true, autoReimbursementValues.limit
won't be assigned CONST.POLICY.AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENT
which is 100
.
https://github.com/Expensify/App/blob/e9c7377bfaa96365a4676fa9eaa58420f959289c/src/libs/actions/Policy/Policy.ts#L4487
https://github.com/Expensify/App/blob/e9c7377bfaa96365a4676fa9eaa58420f959289c/src/libs/actions/Policy/Policy.ts#L4489-L4495
Since autoReimbursementValues.limit
is not updated above, it will default to policy.autoReimbursementValues.limit
which has a value of 0
Then when the user disables Auto-pay approved reports
, enabled
is false, autoReimbursementValues.limit
will be assigned CONST.POLICY.AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENT
which is 100
.
Then when the user enables they will see 100
We should remove !
before enable
so that we should assign a default value of 100 to autoReimbursementValues.limit
every time the user enables the switch.
https://github.com/Expensify/App/blob/e9c7377bfaa96365a4676fa9eaa58420f959289c/src/libs/actions/Policy/Policy.ts#L4487
We can set CONST.POLICY.AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENT` to 0 to make the default value of Auto-pay approved reports amount to 0
In Step 4, when enabling "Auto-pay approved reports" for the first time, it is 0. In Step 7, after disabling and reenabling it, it becomes 100.
When we enable we update nothing in optimistic data then the default limit amount is 0. After we disable and enable again, the amount is 100 because it's updated in optimistic data when we disable the limit amount.
We should change !enabled
condition here to enabled
to update the correct optimistic data.
I checked after reset cache and restart again the amount limit still is 0
so we also need a back-end change to update the correct limit amount value when we enable Auto-pay approved reports
I couldn't reproduce it 100% on the first try. The first time I tried it, I saw $100 initially, but then when I toggled the setting back off, the app crashed. When I reloaded, and tried a second time, I saw the behavior of defaulting to $0.
Then, when I tried with a second workspace, I saw the bug on the first try. So it def exists, and maybe the crash is a related issue? Both are shown below:
https://github.com/user-attachments/assets/5c207171-0836-4874-9207-0b4adafce6fa
https://github.com/user-attachments/assets/74ed2f59-04dc-4d5e-a673-5fdc6196e75c
@DylanDylann assigning you as C+ here as I see you worked on the original PR
cc @marcaaron too as I see you're the project lead
Job added to Upwork: https://www.upwork.com/jobs/~021835706244754359508
Current assignee @DylanDylann is eligible for the External assigner, not assigning anyone new.
If this is a FE fix, and @BrtqKr is available, that makes sense to me as I see Software Mansion is working on this project
@joekaufmanexpensify did you see any JS console logs when the crash happened?
This issue LGTM. I assigned myself so I can help look into the backend changes. @nkdengineer's proposal sounds correct and we will need some kind of change.
I also noticed that the current code is wrong as it sets the autoApproval.auditRate
to 5
which is not correct. It should be a float value as per the design doc:
Random report audit
Command name: SetPolicyAutomaticApprovalAuditRate
API request parameters: policyID: String, auditRate: Int
New values:
{
autoApproval: {
auditRate: Float
}
}
API Note: We will accept Int values to the API, but end up using this as a fraction so 1 = 0.1 and 100 = 1. Values over 100 are not permitted.
I think the best thing would be to just make it a float value in the Onyx data and for what gets sent to the API. So the new "default" would be 0.05
not 5
. Does it make sense?
I think I'm gonna take over this whole issue sorry. It's just gonna be easier for me to implement than to explain exactly what needs to be done.
@joekaufmanexpensify did you see any JS console logs when the crash happened?
I did not at the time. I just tried again a few times now and can no longer reproduce the crash behavior, so thinking we can do nothing if/until it comes up again.
Ok looked at this some more today. We are also sending the incorrect params to the API. Fixing it now...
Various PRs in review here
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.34-2 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+kh010901@applause.expensifail.com Issue reported by: Applause Internal Team
Action Performed:
Expected Result:
Since the default value after reenabling "Auto-pay approved reports" is 100 (Step 7), when enabling it for the first time (Step 4), the value should be 100.
Actual Result:
In Step 4, when enabling "Auto-pay approved reports" for the first time, it is 0. In Step 7, after disabling and reenabling it, it becomes 100.
Workaround:
Unknown
Platforms:
Screenshots/Videos
https://github.com/user-attachments/assets/6df166cd-75df-42f2-a266-f0ae39b64c95
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @